| 6129 |
// UTF-8で受信データを処理する |
// UTF-8で受信データを処理する |
| 6130 |
// returns TRUE if b is processed |
// returns TRUE if b is processed |
| 6131 |
// (actually allways returns TRUE) |
// (actually allways returns TRUE) |
| 6132 |
static BOOL ParseFirstUTF8(BYTE b, int proc_combining) |
static BOOL ParseFirstUTF8(BYTE b) |
| 6133 |
{ |
{ |
| 6134 |
static BYTE buf[4]; |
static BYTE buf[4]; |
| 6135 |
static int count = 0; |
static int count = 0; |
|
static int can_combining = 0; |
|
|
static unsigned int first_code; |
|
|
static int first_code_index; |
|
| 6136 |
|
|
| 6137 |
unsigned int code; |
unsigned int code; |
|
unsigned short cset; |
|
| 6138 |
|
|
| 6139 |
if (ts.FallbackToCP932 && Fallbacked) { |
if (ts.FallbackToCP932 && Fallbacked) { |
| 6140 |
return ParseFirstJP(b); |
return ParseFirstJP(b); |
| 6144 |
// 1バイト目および2バイト目がASCIIの場合は、すべてASCII出力とする。 |
// 1バイト目および2バイト目がASCIIの場合は、すべてASCII出力とする。 |
| 6145 |
// 1バイト目がC1制御文字(0x80-0x9f)の場合も同様。 |
// 1バイト目がC1制御文字(0x80-0x9f)の場合も同様。 |
| 6146 |
if (count == 0 || count == 1) { |
if (count == 0 || count == 1) { |
|
if (proc_combining == 1 && can_combining == 1) { |
|
|
PutU32(first_code); |
|
|
can_combining = 0; |
|
|
} |
|
|
|
|
| 6147 |
if (count == 1) { |
if (count == 1) { |
| 6148 |
ParseASCII(buf[0]); |
ParseASCII(buf[0]); |
| 6149 |
} |
} |
| 6162 |
if ((buf[0] & 0xe0) == 0xc0) { |
if ((buf[0] & 0xe0) == 0xc0) { |
| 6163 |
if ((buf[1] & 0xc0) == 0x80) { |
if ((buf[1] & 0xc0) == 0x80) { |
| 6164 |
|
|
|
if (proc_combining == 1 && can_combining == 1) { |
|
|
PutU32(first_code); |
|
|
can_combining = 0; |
|
|
} |
|
|
|
|
| 6165 |
code = ((buf[0] & 0x1f) << 6); |
code = ((buf[0] & 0x1f) << 6); |
| 6166 |
code |= ((buf[1] & 0x3f)); |
code |= ((buf[1] & 0x3f)); |
| 6167 |
|
|
| 6192 |
code |= ((buf[1] & 0x3f) << 6); |
code |= ((buf[1] & 0x3f) << 6); |
| 6193 |
code |= ((buf[2] & 0x3f)); |
code |= ((buf[2] & 0x3f)); |
| 6194 |
|
|
|
if (proc_combining == 1) { |
|
|
if (can_combining == 0) { |
|
|
first_code_index = UnicodeGetIndexOfCombiningFirstCode(code); |
|
|
if (first_code_index != -1) { |
|
|
can_combining = 1; |
|
|
first_code = code; |
|
|
count = 0; |
|
|
return (TRUE); |
|
|
} |
|
|
} else { |
|
|
can_combining = 0; |
|
|
cset = UnicodeGetPrecomposedChar(first_code_index, first_code, code); |
|
|
if (cset != 0) { // success |
|
|
code = cset; |
|
|
|
|
|
} else { // error |
|
|
// 2つめの文字が半濁点の1文字目に相当する場合は、再度検索を続ける。(2005.10.15 yutaka) |
|
|
first_code_index = UnicodeGetIndexOfCombiningFirstCode(code); |
|
|
if (first_code_index != -1) { |
|
|
// 1つめの文字はそのまま出力する |
|
|
PutU32(first_code); |
|
|
|
|
|
can_combining = 1; |
|
|
first_code = code; |
|
|
count = 0; |
|
|
return (TRUE); |
|
|
} |
|
|
|
|
|
PutU32(first_code); |
|
|
PutU32(code); |
|
|
count = 0; |
|
|
return (TRUE); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
| 6195 |
PutU32(code); |
PutU32(code); |
| 6196 |
|
|
| 6197 |
skip: |
skip: |
| 6242 |
{ |
{ |
| 6243 |
switch (ts.Language) { |
switch (ts.Language) { |
| 6244 |
case IdUtf8: |
case IdUtf8: |
| 6245 |
ParseFirstUTF8(b, ts.KanjiCode == IdUTF8m); |
ParseFirstUTF8(b); |
| 6246 |
return; |
return; |
| 6247 |
|
|
| 6248 |
case IdJapanese: |
case IdJapanese: |
| 6249 |
switch (ts.KanjiCode) { |
switch (ts.KanjiCode) { |
| 6250 |
case IdUTF8: |
case IdUTF8: |
| 6251 |
if (ParseFirstUTF8(b, 0)) { |
if (ParseFirstUTF8(b)) { |
| 6252 |
return; |
return; |
| 6253 |
} |
} |
| 6254 |
break; |
break; |
| 6255 |
case IdUTF8m: |
case IdUTF8m: |
| 6256 |
if (ParseFirstUTF8(b, 1)) { |
if (ParseFirstUTF8(b)) { |
| 6257 |
return; |
return; |
| 6258 |
} |
} |
| 6259 |
break; |
break; |
| 6267 |
case IdKorean: |
case IdKorean: |
| 6268 |
switch (ts.KanjiCode) { |
switch (ts.KanjiCode) { |
| 6269 |
case IdUTF8: |
case IdUTF8: |
| 6270 |
if (ParseFirstUTF8(b, 0)) { |
if (ParseFirstUTF8(b)) { |
| 6271 |
return; |
return; |
| 6272 |
} |
} |
| 6273 |
break; |
break; |
| 6274 |
case IdUTF8m: |
case IdUTF8m: |
| 6275 |
if (ParseFirstUTF8(b, 1)) { |
if (ParseFirstUTF8(b)) { |
| 6276 |
return; |
return; |
| 6277 |
} |
} |
| 6278 |
break; |
break; |
| 6286 |
case IdRussian: |
case IdRussian: |
| 6287 |
switch (ts.KanjiCode) { |
switch (ts.KanjiCode) { |
| 6288 |
case IdUTF8: |
case IdUTF8: |
| 6289 |
if (ParseFirstUTF8(b, 0)) { |
if (ParseFirstUTF8(b)) { |
| 6290 |
return; |
return; |
| 6291 |
} |
} |
| 6292 |
break; |
break; |
| 6300 |
case IdChinese: |
case IdChinese: |
| 6301 |
switch (ts.KanjiCode) { |
switch (ts.KanjiCode) { |
| 6302 |
case IdUTF8: |
case IdUTF8: |
| 6303 |
if (ParseFirstUTF8(b, 0)) { |
if (ParseFirstUTF8(b)) { |
| 6304 |
return; |
return; |
| 6305 |
} |
} |
| 6306 |
break; |
break; |