| 52 |
#include "telnet.h" |
#include "telnet.h" |
| 53 |
#include "ttime.h" |
#include "ttime.h" |
| 54 |
#include "clipboar.h" |
#include "clipboar.h" |
| 55 |
#include "../ttpcmn/language.h" |
#include "codeconv.h" |
| 56 |
|
#include "codeconv.h" |
| 57 |
|
|
| 58 |
#include "vtterm.h" |
#include "vtterm.h" |
| 59 |
|
|
| 5409 |
} |
} |
| 5410 |
|
|
| 5411 |
// |
// |
|
// UTF-8 |
|
|
// |
|
|
#include "uni2sjis.map" |
|
|
#include "unisym2decsp.map" |
|
|
|
|
|
|
|
|
// |
|
| 5412 |
// Unicode Combining Character Support |
// Unicode Combining Character Support |
| 5413 |
// |
// |
| 5414 |
#include "uni_combining.map" |
#include "uni_combining.map" |
| 5461 |
return (index); |
return (index); |
| 5462 |
} |
} |
| 5463 |
|
|
| 5464 |
// unicode(UTF-16,wchar_t)をバッファへ書き込む |
// unicode(UTF-32,wchar_t)をバッファへ書き込む |
| 5465 |
static void UnicodeToCP932(unsigned int code) |
static void UnicodeToCP932(unsigned int code) |
| 5466 |
{ |
{ |
| 5467 |
wchar_t wchar = (wchar_t)code; |
wchar_t wchar; |
| 5468 |
int ret; |
int ret; |
| 5469 |
char mbchar[2]; |
char mbchar[2]; |
| 5470 |
unsigned short cset; |
unsigned short cset; |
| 5471 |
|
|
| 5472 |
|
if (code >= 0x10000) { |
| 5473 |
|
goto unknown; |
| 5474 |
|
} |
| 5475 |
|
wchar = (wchar_t)code; |
| 5476 |
|
|
| 5477 |
// UnicodeからDEC特殊文字へのマッピング |
// UnicodeからDEC特殊文字へのマッピング |
| 5478 |
if (ts.UnicodeDecSpMapping) { |
if (ts.UnicodeDecSpMapping) { |
| 5479 |
cset = ConvertUnicode(wchar, mapUnicodeSymbolToDecSp, MAPSIZE(mapUnicodeSymbolToDecSp)); |
cset = UTF32ToDecSp(wchar); |
| 5480 |
if (((cset >> 8) & ts.UnicodeDecSpMapping) != 0) { |
if (((cset >> 8) & ts.UnicodeDecSpMapping) != 0) { |
| 5481 |
PutDecSp(cset & 0xff); |
PutDecSp(cset & 0xff); |
| 5482 |
return; |
return; |
| 5484 |
} |
} |
| 5485 |
|
|
| 5486 |
// Unicode -> 内部コード(ts.CodePage)へ変換して出力 |
// Unicode -> 内部コード(ts.CodePage)へ変換して出力 |
| 5487 |
ret = WideCharToMultiByte(ts.CodePage, 0, &wchar, 1, mbchar, 2, NULL, NULL); |
if (ts.CodePage == 932) { |
| 5488 |
|
ret = (int)UTF16ToCP932(&wchar, 1, &cset); |
| 5489 |
|
if (ret == 0) { |
| 5490 |
|
// 変換できなかった |
| 5491 |
|
; |
| 5492 |
|
} else if (cset < 0x100) { |
| 5493 |
|
// 1byte文字 |
| 5494 |
|
mbchar[0] = (char)cset; |
| 5495 |
|
ret = 1; |
| 5496 |
|
} else { |
| 5497 |
|
// 2byte文字 |
| 5498 |
|
mbchar[0] = (char)(cset >> 8); |
| 5499 |
|
mbchar[1] = (char)(cset & 0xff); |
| 5500 |
|
ret = 2; |
| 5501 |
|
} |
| 5502 |
|
} else { |
| 5503 |
|
ret = WideCharToMultiByte(ts.CodePage, 0, &wchar, 1, mbchar, 2, NULL, NULL); |
| 5504 |
|
} |
| 5505 |
if (ret == 1 && mbchar[0] == '?' && code != '?') { |
if (ret == 1 && mbchar[0] == '?' && code != '?') { |
| 5506 |
// 変換できなかったとき、ret=1, '?' を返してくる |
// 変換できなかったとき、ret=1, '?' を返してくる |
| 5507 |
ret = 0; |
ret = 0; |
| 5508 |
} |
} |
| 5509 |
switch (ret) { |
switch (ret) { |
| 5510 |
case 0: |
case 0: |
| 5511 |
if (ts.CodePage == 932) { |
unknown: |
|
// CP932 |
|
|
// U+301Cなどは変換できない。Unicode -> Shift_JISへ変換してみる。 |
|
|
cset = ConvertUnicode(code, mapUnicodeToSJIS, MAPSIZE(mapUnicodeToSJIS)); |
|
|
if (cset != 0) { |
|
|
Kanji = cset & 0xff00; |
|
|
PutKanji(cset & 0x00ff); |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
| 5512 |
PutChar('?'); |
PutChar('?'); |
| 5513 |
if (ts.UnknownUnicodeCharaAsWide) { |
if (ts.UnknownUnicodeCharaAsWide) { |
| 5514 |
PutChar('?'); |
PutChar('?'); |