33 #include "sysconfig.h" 35 #ifdef GSC_COMP_ENABLE_FATFS 37 #define MAX_CONVERT_LEN FF_MAX_LFN 39 #define MAX_CONVERT_LEN 255 49 #ifdef GSC_COMP_ENABLE_FATFS 59 ushort rt = ff_oem2uni(sjiscode, FF_CODE_PAGE);
79 while((*sjisstr) != 0) {
89 wch = (
ushort)((((
ushort)(*sjisstr)) << 8) + (*(sjisstr+1)));
96 for(i=0; i<clen; i++) {
126 static uchar utf8str[MAX_CONVERT_LEN+1];
147 code[0] = (
uchar)(utf16code >> 8);
148 code[1] = (
uchar)(utf16code & 0xff);
150 if(utf16code < 0x80) {
152 utf8code[0] = code[1];
154 }
else if(utf16code < 0x800) {
156 utf8code[0] = (
uchar)0xC0 + ((code[0] & 0x7) << 2) + ((code[1] & 0xC0) >> 6);
157 utf8code[1] = (
uchar)0x80 + (code[1] & 0x3F);
161 utf8code[2] = (
uchar)0x80 + (code[1] & 0x3F);
162 utf8code[1] = (
uchar)0x80 + ((code[1] & 0xC0) >> 6) + ((code[0] & 0xF) << 2);
163 utf8code[0] = (
uchar)0xE0 + ((code[0] & 0xF0) >> 4);
181 unsigned int len = 0;
182 uchar *u8p = utf8str;
185 while((*u16p) != 0) {
199 for(i=0; i<clen; i++) {
217 XDUMP(0x01, (
unsigned char *)utf16str, len);
218 XDUMP(0x01, utf8str, len);
232 static uchar utf8str[MAX_CONVERT_LEN+1];
249 if(*utf8code < 0x80) {
250 *utf16code = *utf8code;
252 }
else if((*utf8code & 0xe0) == 0xc0) {
254 *utf16code = (
unsigned short)(((((
unsigned short)utf8code[0] & 0x1f) >> 2) << 8) +
255 ((utf8code[0] & 0x03) << 6) +
256 (utf8code[1] & 0x3f));
258 }
else if((*utf8code & 0xf0) == 0xe0) {
260 *utf16code = (
unsigned short)(((((
unsigned short)utf8code[0] & 0x0f) << 4) << 8) +
261 ((((
unsigned short)utf8code[1] & 0x3c) >> 2) << 8) +
262 ((utf8code[1] & 0x03) << 6) +
263 (utf8code[2] & 0x3f));
265 }
else if((*utf8code & 0xf8) == 0xf0) {
268 }
else if((*utf8code & 0xfc) == 0xf8) {
271 }
else if((*utf8code & 0xfe) == 0xfc) {
292 unsigned int len = 0;
294 while((*utf8str) != 0) {
296 if(*utf8str < 0x80) {
297 *utf16str = *utf8str;
307 if((len+1) < count) {
unsigned char uchar
GadgetSeedの文字(列)は unsigned char 型となる
int utf8str_to_utf16str(ushort *utf16str, uchar *utf8str, unsigned int count)
UTF-8 文字列から UTF-16 文字列へ変換
int utf8code_to_utf16code(ushort *utf16code, uchar *utf8code)
UTF-8 文字から UTF-16 文字へ変換
uchar * sj2utf8(uchar *sjisstr)
SJIS 文字列から最大文字バイト数固定 UTF-8 文字列へ変換
ushort sjiscode_to_utf16code(ushort sjiscode)
SJIS から UTF-16 へ変換
uchar * utf162utf8(ushort *utf16str)
UTF-16 文字列から最大文字バイト数固定 UTF-8 文字列へ変換
int utf16code_to_utf8code(uchar *utf8code, ushort utf16code)
UTF-16 文字から UTF-8 文字へ変換
uchar * sjisstr_to_utf8str(uchar *utf8str, uchar *sjisstr, unsigned int count)
SJIS 文字列から UTF-8 文字列へ変換
unsigned short ushort
2バイト(UTF-16)文字
int utf16str_to_utf8str(uchar *utf8str, ushort *utf16str, unsigned int count)
UTF-16 文字列から UTF-8 文字列へ変換