Move more things sj4charset
This commit is contained in:
parent
bbed5ba02d
commit
a228b83a15
8 changed files with 315 additions and 39 deletions
|
|
@ -5,6 +5,13 @@
|
||||||
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
|
enum SJ4CHARSET {
|
||||||
|
SJ4EUCJP = 0,
|
||||||
|
SJ4SJIS,
|
||||||
|
SJ4UTF8,
|
||||||
|
SJ4UTF16
|
||||||
|
};
|
||||||
|
|
||||||
int sj4_from_sjis(u_char* out, const u_char* in, int len);
|
int sj4_from_sjis(u_char* out, const u_char* in, int len);
|
||||||
int sj4_from_utf8(u_char* out, const u_char* in, int len);
|
int sj4_from_utf8(u_char* out, const u_char* in, int len);
|
||||||
int sj4_from_utf16(u_char* out, const u_char* in, int len);
|
int sj4_from_utf16(u_char* out, const u_char* in, int len);
|
||||||
|
|
@ -12,4 +19,7 @@ int sj4_to_sjis(u_char* out, const u_char* in, int len);
|
||||||
int sj4_to_utf8(u_char* out, const u_char* in, int len);
|
int sj4_to_utf8(u_char* out, const u_char* in, int len);
|
||||||
int sj4_to_utf16(u_char* out, const u_char* in, int len);
|
int sj4_to_utf16(u_char* out, const u_char* in, int len);
|
||||||
|
|
||||||
|
int sj4_charset_to(int type, void* output, const void* input, int len);
|
||||||
|
int sj4_charset_from(int type, void* output, const void* input, int len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
#ifndef __SJ4IME_H__
|
#ifndef __SJ4IME_H__
|
||||||
#define __SJ4IME_H__
|
#define __SJ4IME_H__
|
||||||
|
|
||||||
#include <sj4lib.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef __SJ4LIB_H__
|
#ifndef __SJ4LIB_H__
|
||||||
#define __SJ4LIB_H__
|
#define __SJ4LIB_H__
|
||||||
|
|
||||||
|
#include <sj_charset.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
/* increase this as needed... */
|
/* increase this as needed... */
|
||||||
|
|
@ -26,13 +27,6 @@ typedef struct sj4kouho {
|
||||||
|
|
||||||
typedef struct sj4lib Sj4Lib;
|
typedef struct sj4lib Sj4Lib;
|
||||||
|
|
||||||
enum SJ4CHARSET {
|
|
||||||
SJ4EUCJP = 0,
|
|
||||||
SJ4SJIS,
|
|
||||||
SJ4UTF8,
|
|
||||||
SJ4UTF16
|
|
||||||
};
|
|
||||||
|
|
||||||
Sj4Lib* sj4_open(int, const char*);
|
Sj4Lib* sj4_open(int, const char*);
|
||||||
int sj4_getkan(Sj4Lib*, const void*, int len, Sj4Kouho*);
|
int sj4_getkan(Sj4Lib*, const void*, int len, Sj4Kouho*);
|
||||||
int sj4_nextkan(Sj4Lib*);
|
int sj4_nextkan(Sj4Lib*);
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
#include "sj_ucs2euc.h"
|
#include "sj_ucs2euc.h"
|
||||||
#include "sj_string.h"
|
#include "sj_string.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef UCS
|
#ifdef UCS
|
||||||
static u_int ucs_to_euc(u_int in) {
|
static u_int ucs_to_euc(u_int in) {
|
||||||
if(in <= 0xffff) {
|
if(in <= 0xffff) {
|
||||||
|
|
@ -285,3 +287,35 @@ int sj4_to_utf16(u_char* out, const u_char* in, int len) {
|
||||||
return w_out - o_out;
|
return w_out - o_out;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef UCS
|
||||||
|
#define CONV(type, to, from, len, mode) \
|
||||||
|
if(type == SJ4EUCJP) { \
|
||||||
|
memcpy(to, from, len); \
|
||||||
|
} else if(type == SJ4SJIS) { \
|
||||||
|
len = sj4_##mode##_sjis(to, from, len); \
|
||||||
|
} else if(type == SJ4UTF8) { \
|
||||||
|
len = sj4_##mode##_utf8(to, from, len); \
|
||||||
|
} else if(type == SJ4UTF16) { \
|
||||||
|
len = sj4_##mode##_utf16(to, from, len); \
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define CONV(type, to, from, len, mode) \
|
||||||
|
if(type == SJ4EUCJP) { \
|
||||||
|
memcpy(to, from, len); \
|
||||||
|
} else if(type == SJ4SJIS) { \
|
||||||
|
len = sj4_##mode##_sjis(to, from, len); \
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int sj4_charset_to(int type, void* output, const void* input, int len) {
|
||||||
|
CONV(type, output, input, len, to);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int sj4_charset_from(int type, void* output, const void* input, int len) {
|
||||||
|
CONV(type, output, input, len, from);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
|
||||||
262
lib/sj4ime/KanaTable
Normal file
262
lib/sj4ime/KanaTable
Normal file
|
|
@ -0,0 +1,262 @@
|
||||||
|
{"KA", "\244\253", ""},
|
||||||
|
{"KI", "\244\255", ""},
|
||||||
|
{"KU", "\244\257", ""},
|
||||||
|
{"KE", "\244\261", ""},
|
||||||
|
{"KO", "\244\263", ""},
|
||||||
|
{"CA", "\244\253", ""},
|
||||||
|
{"CI", "\244\255", ""},
|
||||||
|
{"CU", "\244\257", ""},
|
||||||
|
{"CE", "\244\261", ""},
|
||||||
|
{"CO", "\244\263", ""},
|
||||||
|
{"KYA", "\244\255\244\343", ""},
|
||||||
|
{"KYI", "\244\255", ""},
|
||||||
|
{"KYU", "\244\255\244\345", ""},
|
||||||
|
{"KYE", "\244\255\244\247", ""},
|
||||||
|
{"KYO", "\244\255\244\347", ""},
|
||||||
|
{"QYA", "\244\255\244\343", ""},
|
||||||
|
{"QYI", "\244\255", ""},
|
||||||
|
{"QYU", "\244\255\244\345", ""},
|
||||||
|
{"QYE", "\244\255\244\247", ""},
|
||||||
|
{"QYO", "\244\255\244\347", ""},
|
||||||
|
{"SA", "\244\265", ""},
|
||||||
|
{"SI", "\244\267", ""},
|
||||||
|
{"SU", "\244\271", ""},
|
||||||
|
{"SE", "\244\273", ""},
|
||||||
|
{"SO", "\244\275", ""},
|
||||||
|
{"SYA", "\244\267\244\343", ""},
|
||||||
|
{"SYI", "\244\267", ""},
|
||||||
|
{"SYU", "\244\267\244\345", ""},
|
||||||
|
{"SYE", "\244\267\244\247", ""},
|
||||||
|
{"SYO", "\244\267\244\347", ""},
|
||||||
|
{"SHA", "\244\267\244\343", ""},
|
||||||
|
{"SHI", "\244\267", ""},
|
||||||
|
{"SHU", "\244\267\244\345", ""},
|
||||||
|
{"SHE", "\244\267\244\247", ""},
|
||||||
|
{"SHO", "\244\267\244\347", ""},
|
||||||
|
{"TA", "\244\277", ""},
|
||||||
|
{"TI", "\244\301", ""},
|
||||||
|
{"TU", "\244\304", ""},
|
||||||
|
{"TE", "\244\306", ""},
|
||||||
|
{"TO", "\244\310", ""},
|
||||||
|
{"TSA", "\244\277", ""},
|
||||||
|
{"TSI", "\244\301", ""},
|
||||||
|
{"TSU", "\244\304", ""},
|
||||||
|
{"TSE", "\244\306", ""},
|
||||||
|
{"TSO", "\244\310", ""},
|
||||||
|
{"THA", "\244\277\244\241", ""},
|
||||||
|
{"THI", "\244\306\244\243", ""},
|
||||||
|
{"THU", "\244\310\244\245", ""},
|
||||||
|
{"TYA", "\244\301\244\343", ""},
|
||||||
|
{"TYI", "\244\301", ""},
|
||||||
|
{"TYU", "\244\301\244\345", ""},
|
||||||
|
{"TYE", "\244\301\244\247", ""},
|
||||||
|
{"TYO", "\244\301\244\347", ""},
|
||||||
|
{"TSYA", "\244\301\244\343", ""},
|
||||||
|
{"TSYI", "\244\301", ""},
|
||||||
|
{"TSYU", "\244\301\244\345", ""},
|
||||||
|
{"TSYE", "\244\301\244\247", ""},
|
||||||
|
{"TSYO", "\244\301\244\347", ""},
|
||||||
|
{"CHA", "\244\301\244\343", ""},
|
||||||
|
{"CHI", "\244\301", ""},
|
||||||
|
{"CHU", "\244\301\244\345", ""},
|
||||||
|
{"CHE", "\244\301\244\247", ""},
|
||||||
|
{"CHO", "\244\301\244\347", ""},
|
||||||
|
{"CYA", "\244\301\244\343", ""},
|
||||||
|
{"CYI", "\244\301", ""},
|
||||||
|
{"CYU", "\244\301\244\345", ""},
|
||||||
|
{"CYE", "\244\301\244\247", ""},
|
||||||
|
{"CYO", "\244\301\244\347", ""},
|
||||||
|
{"NA", "\244\312", ""},
|
||||||
|
{"NI", "\244\313", ""},
|
||||||
|
{"NU", "\244\314", ""},
|
||||||
|
{"NE", "\244\315", ""},
|
||||||
|
{"NO", "\244\316", ""},
|
||||||
|
{"NYA", "\244\313\244\343", ""},
|
||||||
|
{"NYI", "\244\313", ""},
|
||||||
|
{"NYU", "\244\313\244\345", ""},
|
||||||
|
{"NYE", "\244\313\244\247", ""},
|
||||||
|
{"NYO", "\244\313\244\347", ""},
|
||||||
|
{"HA", "\244\317", ""},
|
||||||
|
{"HI", "\244\322", ""},
|
||||||
|
{"HU", "\244\325", ""},
|
||||||
|
{"HE", "\244\330", ""},
|
||||||
|
{"HO", "\244\333", ""},
|
||||||
|
{"HYA", "\244\322\244\343", ""},
|
||||||
|
{"HYI", "\244\322", ""},
|
||||||
|
{"HYU", "\244\322\244\345", ""},
|
||||||
|
{"HYE", "\244\322\244\247", ""},
|
||||||
|
{"HYO", "\244\322\244\347", ""},
|
||||||
|
{"FA", "\244\325\244\241", ""},
|
||||||
|
{"FI", "\244\325\244\243", ""},
|
||||||
|
{"FU", "\244\325", ""},
|
||||||
|
{"FE", "\244\325\244\247", ""},
|
||||||
|
{"FO", "\244\325\244\251", ""},
|
||||||
|
{"FYA", "\244\325\244\343", ""},
|
||||||
|
{"FYI", "\244\325\244\243", ""},
|
||||||
|
{"FYU", "\244\325\244\345", ""},
|
||||||
|
{"FYE", "\244\325\244\247", ""},
|
||||||
|
{"FYO", "\244\325\244\347", ""},
|
||||||
|
{"MA", "\244\336", ""},
|
||||||
|
{"MI", "\244\337", ""},
|
||||||
|
{"MU", "\244\340", ""},
|
||||||
|
{"ME", "\244\341", ""},
|
||||||
|
{"MO", "\244\342", ""},
|
||||||
|
{"MYA", "\244\337\244\343", ""},
|
||||||
|
{"MYI", "\244\337", ""},
|
||||||
|
{"MYU", "\244\337\244\345", ""},
|
||||||
|
{"MYE", "\244\337\244\247", ""},
|
||||||
|
{"MYO", "\244\337\244\347", ""},
|
||||||
|
{"YA", "\244\344", ""},
|
||||||
|
{"YI", "\244\244", ""},
|
||||||
|
{"YU", "\244\346", ""},
|
||||||
|
{"YE", "\244\244\244\247", ""},
|
||||||
|
{"YO", "\244\350", ""},
|
||||||
|
{"RA", "\244\351", ""},
|
||||||
|
{"RI", "\244\352", ""},
|
||||||
|
{"RU", "\244\353", ""},
|
||||||
|
{"RE", "\244\354", ""},
|
||||||
|
{"RO", "\244\355", ""},
|
||||||
|
{"LA", "\244\351", ""},
|
||||||
|
{"LI", "\244\352", ""},
|
||||||
|
{"LU", "\244\353", ""},
|
||||||
|
{"LE", "\244\354", ""},
|
||||||
|
{"LO", "\244\355", ""},
|
||||||
|
{"RYA", "\244\352\244\343", ""},
|
||||||
|
{"RYI", "\244\352", ""},
|
||||||
|
{"RYU", "\244\352\244\345", ""},
|
||||||
|
{"RYE", "\244\352\244\247", ""},
|
||||||
|
{"RYO", "\244\352\244\347", ""},
|
||||||
|
{"LYA", "\244\352\244\343", ""},
|
||||||
|
{"LYI", "\244\352", ""},
|
||||||
|
{"LYU", "\244\352\244\345", ""},
|
||||||
|
{"LYE", "\244\352\244\247", ""},
|
||||||
|
{"LYO", "\244\352\244\347", ""},
|
||||||
|
{"WA", "\244\357", ""},
|
||||||
|
{"WI", "\244\246\244\243", ""},
|
||||||
|
{"WU", "\244\246", ""},
|
||||||
|
{"WE", "\244\246\244\247", ""},
|
||||||
|
{"WO", "\244\362", ""},
|
||||||
|
{"GA", "\244\254", ""},
|
||||||
|
{"GI", "\244\256", ""},
|
||||||
|
{"GU", "\244\260", ""},
|
||||||
|
{"GE", "\244\262", ""},
|
||||||
|
{"GO", "\244\264", ""},
|
||||||
|
{"GYA", "\244\256\244\343", ""},
|
||||||
|
{"GYI", "\244\256", ""},
|
||||||
|
{"GYU", "\244\256\244\345", ""},
|
||||||
|
{"GYE", "\244\256\244\247", ""},
|
||||||
|
{"GYO", "\244\256\244\347", ""},
|
||||||
|
{"ZA", "\244\266", ""},
|
||||||
|
{"ZI", "\244\270", ""},
|
||||||
|
{"ZU", "\244\272", ""},
|
||||||
|
{"ZE", "\244\274", ""},
|
||||||
|
{"ZO", "\244\276", ""},
|
||||||
|
{"ZYA", "\244\270\244\343", ""},
|
||||||
|
{"ZYI", "\244\270", ""},
|
||||||
|
{"ZYU", "\244\270\244\345", ""},
|
||||||
|
{"ZYE", "\244\270\244\247", ""},
|
||||||
|
{"ZYO", "\244\270\244\347", ""},
|
||||||
|
{"JA", "\244\270\244\343", ""},
|
||||||
|
{"JI", "\244\270", ""},
|
||||||
|
{"JU", "\244\270\244\345", ""},
|
||||||
|
{"JE", "\244\270\244\247", ""},
|
||||||
|
{"JO", "\244\270\244\347", ""},
|
||||||
|
{"JYA", "\244\270\244\343", ""},
|
||||||
|
{"JYI", "\244\270", ""},
|
||||||
|
{"JYU", "\244\270\244\345", ""},
|
||||||
|
{"JYE", "\244\270\244\247", ""},
|
||||||
|
{"JYO", "\244\270\244\347", ""},
|
||||||
|
{"DA", "\244\300", ""},
|
||||||
|
{"DI", "\244\302", ""},
|
||||||
|
{"DU", "\244\305", ""},
|
||||||
|
{"DE", "\244\307", ""},
|
||||||
|
{"DO", "\244\311", ""},
|
||||||
|
{"DYA", "\244\302\244\343", ""},
|
||||||
|
{"DYI", "\244\302", ""},
|
||||||
|
{"DYU", "\244\302\244\345", ""},
|
||||||
|
{"DYE", "\244\302\244\247", ""},
|
||||||
|
{"DYO", "\244\302\244\347", ""},
|
||||||
|
{"DHA", "\244\300\244\241", ""},
|
||||||
|
{"DHI", "\244\307\244\243", ""},
|
||||||
|
{"DHU", "\244\311\244\245", ""},
|
||||||
|
{"DHYU", "\244\307\244\345", ""},
|
||||||
|
{"BA", "\244\320", ""},
|
||||||
|
{"BI", "\244\323", ""},
|
||||||
|
{"BU", "\244\326", ""},
|
||||||
|
{"BE", "\244\331", ""},
|
||||||
|
{"BO", "\244\334", ""},
|
||||||
|
{"BYA", "\244\323\244\343", ""},
|
||||||
|
{"BYI", "\244\323", ""},
|
||||||
|
{"BYU", "\244\323\244\345", ""},
|
||||||
|
{"BYE", "\244\323\244\247", ""},
|
||||||
|
{"BYO", "\244\323\244\347", ""},
|
||||||
|
{"VA", "\245\364\244\241", ""},
|
||||||
|
{"VI", "\245\364\244\243", ""},
|
||||||
|
{"VU", "\245\364", ""},
|
||||||
|
{"VE", "\245\364\244\247", ""},
|
||||||
|
{"VO", "\245\364\244\251", ""},
|
||||||
|
{"VYA", "\244\323\244\343", ""},
|
||||||
|
{"VYI", "\244\323", ""},
|
||||||
|
{"VYU", "\244\323\244\345", ""},
|
||||||
|
{"VYE", "\244\323\244\247", ""},
|
||||||
|
{"VYO", "\244\323\244\347", ""},
|
||||||
|
{"PA", "\244\321", ""},
|
||||||
|
{"PI", "\244\324", ""},
|
||||||
|
{"PU", "\244\327", ""},
|
||||||
|
{"PE", "\244\332", ""},
|
||||||
|
{"PO", "\244\335", ""},
|
||||||
|
{"PYA", "\244\324\244\343", ""},
|
||||||
|
{"PYI", "\244\324", ""},
|
||||||
|
{"PYU", "\244\324\244\345", ""},
|
||||||
|
{"PYE", "\244\324\244\247", ""},
|
||||||
|
{"PYO", "\244\324\244\347", ""},
|
||||||
|
{"QA", "\244\257\244\241", ""},
|
||||||
|
{"QI", "\244\257\244\243", ""},
|
||||||
|
{"QU", "\244\257\244\245", ""},
|
||||||
|
{"QE", "\244\257\244\247", ""},
|
||||||
|
{"QO", "\244\257\244\251", ""},
|
||||||
|
{"N", "\244\363", ""},
|
||||||
|
{"NN", "\244\363", ""},
|
||||||
|
{"KK", "\244\303", "K"},
|
||||||
|
{"SS", "\244\303", "S"},
|
||||||
|
{"TT", "\244\303", "T"},
|
||||||
|
{"HH", "\244\303", "H"},
|
||||||
|
{"MM", "\244\303", "M"},
|
||||||
|
{"YY", "\244\303", "Y"},
|
||||||
|
{"RR", "\244\303", "R"},
|
||||||
|
{"LL", "\244\303", "L"},
|
||||||
|
{"WW", "\244\303", "W"},
|
||||||
|
{"GG", "\244\303", "G"},
|
||||||
|
{"ZZ", "\244\303", "Z"},
|
||||||
|
{"DD", "\244\303", "D"},
|
||||||
|
{"BB", "\244\303", "B"},
|
||||||
|
{"PP", "\244\303", "P"},
|
||||||
|
{"CC", "\244\303", "C"},
|
||||||
|
{"FF", "\244\303", "F"},
|
||||||
|
{"JJ", "\244\303", "J"},
|
||||||
|
{"VV", "\244\303", "V"},
|
||||||
|
{"QQ", "\244\303", "Q"},
|
||||||
|
{"XX", "\244\303", "X"},
|
||||||
|
{"XA", "\244\241", ""},
|
||||||
|
{"XI", "\244\243", ""},
|
||||||
|
{"XU", "\244\245", ""},
|
||||||
|
{"XE", "\244\247", ""},
|
||||||
|
{"XO", "\244\251", ""},
|
||||||
|
{"XYA", "\244\343", ""},
|
||||||
|
{"XYI", "\244\243", ""},
|
||||||
|
{"XYU", "\244\345", ""},
|
||||||
|
{"XYE", "\244\247", ""},
|
||||||
|
{"XYO", "\244\347", ""},
|
||||||
|
{"XTU", "\244\303", ""},
|
||||||
|
{"XTSU", "\244\303", ""},
|
||||||
|
{"XWA", "\244\356", ""},
|
||||||
|
{"XKA", "\245\365", ""},
|
||||||
|
{"XKE", "\245\366", ""},
|
||||||
|
{"X,", "\241\253", ""},
|
||||||
|
{"X.", "\241\254", ""},
|
||||||
|
{"~", "\217\242\267", ""},
|
||||||
|
{"A", "\244\242", ""},
|
||||||
|
{"I", "\244\244", ""},
|
||||||
|
{"U", "\244\246", ""},
|
||||||
|
{"E", "\244\250", ""},
|
||||||
|
{"O", "\244\252", ""}
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#include <sj4ime.h>
|
#include <sj4ime.h>
|
||||||
|
|
||||||
|
#include <sj4lib.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
struct sj4ime {
|
struct sj4ime {
|
||||||
|
|
|
||||||
|
|
@ -39,34 +39,13 @@ Sj4Lib* sj4_open(int charset, const char* dic) {
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef UCS
|
|
||||||
#define ICONV(to, from, len, mode) \
|
|
||||||
if(ctx->charset == SJ4EUCJP) { \
|
|
||||||
memcpy(to, from, len); \
|
|
||||||
} else if(ctx->charset == SJ4SJIS) { \
|
|
||||||
len = sj4_##mode##_sjis(to, from, len); \
|
|
||||||
} else if(ctx->charset == SJ4UTF8) { \
|
|
||||||
len = sj4_##mode##_utf8(to, from, len); \
|
|
||||||
} else if(ctx->charset == SJ4UTF16) { \
|
|
||||||
len = sj4_##mode##_utf16(to, from, len); \
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define ICONV(to, from, len, mode) \
|
|
||||||
if(ctx->charset == SJ4EUCJP) { \
|
|
||||||
memcpy(to, from, len); \
|
|
||||||
} else if(ctx->charset == SJ4SJIS) { \
|
|
||||||
len = sj4_##mode##_sjis(to, from, len); \
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define RUNME(PROC) \
|
#define RUNME(PROC) \
|
||||||
PROC \
|
PROC \
|
||||||
\
|
\
|
||||||
len2 = strlen(ctx->outbuf + sizeof(STDYOUT)); \
|
len2 = sj4_charset_to(ctx->charset, ctx->kouho->buffer.raw, ctx->outbuf + sizeof(STDYOUT), strlen(ctx->outbuf + sizeof(STDYOUT))); \
|
||||||
ICONV(ctx->kouho->buffer.raw, ctx->outbuf + sizeof(STDYOUT), len2, to); \
|
|
||||||
\
|
\
|
||||||
memcpy(ctx->wrkbuf, ctx->inbuf, len); \
|
memcpy(ctx->wrkbuf, ctx->inbuf, len); \
|
||||||
ICONV(ctx->wrk2buf, ctx->wrkbuf, len, to); \
|
len = sj4_charset_to(ctx->charset, ctx->wrk2buf, ctx->wrkbuf, len); \
|
||||||
if(ctx->charset == SJ4UTF16) { \
|
if(ctx->charset == SJ4UTF16) { \
|
||||||
int i; \
|
int i; \
|
||||||
for(i = 0; i < sizeof(wchar_t); i++) ctx->wrk2buf[len * sizeof(wchar_t) + i] = 0; \
|
for(i = 0; i < sizeof(wchar_t); i++) ctx->wrk2buf[len * sizeof(wchar_t) + i] = 0; \
|
||||||
|
|
@ -82,18 +61,15 @@ Sj4Lib* sj4_open(int charset, const char* dic) {
|
||||||
\
|
\
|
||||||
return ctx->charset == SJ4UTF16 ? wcslen((wchar_t*)ctx->wrk2buf) : strlen(ctx->wrk2buf);
|
return ctx->charset == SJ4UTF16 ? wcslen((wchar_t*)ctx->wrk2buf) : strlen(ctx->wrk2buf);
|
||||||
|
|
||||||
#define RUNME2(PROC) \
|
|
||||||
ICONV(ctx->inbuf, input, len, from); \
|
|
||||||
\
|
|
||||||
RUNME(PROC)
|
|
||||||
|
|
||||||
int sj4_getkan(Sj4Lib* ctx, const void* input, int len, Sj4Kouho* kouho) {
|
int sj4_getkan(Sj4Lib* ctx, const void* input, int len, Sj4Kouho* kouho) {
|
||||||
int len2;
|
int len2;
|
||||||
|
|
||||||
memset(kouho, 0, sizeof(*kouho));
|
memset(kouho, 0, sizeof(*kouho));
|
||||||
ctx->kouho = kouho;
|
ctx->kouho = kouho;
|
||||||
|
|
||||||
RUNME2({
|
len = sj4_charset_from(ctx->charset, ctx->inbuf, input, len);
|
||||||
|
|
||||||
|
RUNME({
|
||||||
len = cl2knj(ctx->ctx, ctx->inbuf, len, ctx->outbuf);
|
len = cl2knj(ctx->ctx, ctx->inbuf, len, ctx->outbuf);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue