| 64 |
|
|
| 65 |
void ParseFirst(BYTE b); |
void ParseFirst(BYTE b); |
| 66 |
|
|
|
#define MAPSIZE(x) (sizeof(x)/sizeof((x)[0])) |
|
| 67 |
#define Accept8BitCtrl ((VTlevel >= 2) && (ts.TermFlag & TF_ACCEPT8BITCTRL)) |
#define Accept8BitCtrl ((VTlevel >= 2) && (ts.TermFlag & TF_ACCEPT8BITCTRL)) |
| 68 |
|
|
| 69 |
/* Parsing modes */ |
/* Parsing modes */ |
| 5711 |
} |
} |
| 5712 |
} |
} |
| 5713 |
|
|
|
// |
|
|
// Unicode Combining Character Support |
|
|
// |
|
|
#include "uni_combining.map" |
|
|
|
|
|
static unsigned short GetPrecomposedChar(int start_index, unsigned short first_code, unsigned short code, |
|
|
const combining_map_t *table, int tmax) |
|
|
{ |
|
|
unsigned short result = 0; |
|
|
int i; |
|
|
|
|
|
for (i = start_index ; i < tmax ; i++) { |
|
|
if (table[i].first_code != first_code) { // 1文字目が異なるなら、以降はもう調べなくてよい。 |
|
|
break; |
|
|
} |
|
|
|
|
|
if (table[i].second_code == code) { |
|
|
result = table[i].precomposed; |
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
return (result); |
|
|
} |
|
|
|
|
|
static int GetIndexOfCombiningFirstCode(unsigned short code, const combining_map_t *table, int tmax) |
|
|
{ |
|
|
int low, mid, high; |
|
|
int index = -1; |
|
|
|
|
|
low = 0; |
|
|
high = tmax - 1; |
|
|
|
|
|
// binary search |
|
|
while (low < high) { |
|
|
mid = (low + high) / 2; |
|
|
if (table[mid].first_code < code) { |
|
|
low = mid + 1; |
|
|
} else { |
|
|
high = mid; |
|
|
} |
|
|
} |
|
|
|
|
|
if (table[low].first_code == code) { |
|
|
while (low >= 0 && table[low].first_code == code) { |
|
|
index = low; |
|
|
low--; |
|
|
} |
|
|
} |
|
|
|
|
|
return (index); |
|
|
} |
|
|
|
|
| 5714 |
// unicode(UTF-32,wchar_t)をバッファへ書き込む |
// unicode(UTF-32,wchar_t)をバッファへ書き込む |
| 5715 |
// TODO @@ |
// TODO @@ |
| 5716 |
#if UNICODE_INTERNAL_BUFF |
#if UNICODE_INTERNAL_BUFF |
| 6013 |
|
|
| 6014 |
if (proc_combining == 1) { |
if (proc_combining == 1) { |
| 6015 |
if (can_combining == 0) { |
if (can_combining == 0) { |
| 6016 |
if ((first_code_index = GetIndexOfCombiningFirstCode( |
first_code_index = UnicodeGetIndexOfCombiningFirstCode(code); |
| 6017 |
code, mapCombiningToPrecomposed, MAPSIZE(mapCombiningToPrecomposed) |
if (first_code_index != -1) { |
|
)) != -1) { |
|
| 6018 |
can_combining = 1; |
can_combining = 1; |
| 6019 |
first_code = code; |
first_code = code; |
| 6020 |
count = 0; |
count = 0; |
| 6022 |
} |
} |
| 6023 |
} else { |
} else { |
| 6024 |
can_combining = 0; |
can_combining = 0; |
| 6025 |
cset = GetPrecomposedChar(first_code_index, first_code, code, mapCombiningToPrecomposed, MAPSIZE(mapCombiningToPrecomposed)); |
cset = UnicodeGetPrecomposedChar(first_code_index, first_code, code); |
| 6026 |
if (cset != 0) { // success |
if (cset != 0) { // success |
| 6027 |
code = cset; |
code = cset; |
| 6028 |
|
|
| 6029 |
} else { // error |
} else { // error |
| 6030 |
// 2つめの文字が半濁点の1文字目に相当する場合は、再度検索を続ける。(2005.10.15 yutaka) |
// 2つめの文字が半濁点の1文字目に相当する場合は、再度検索を続ける。(2005.10.15 yutaka) |
| 6031 |
if ((first_code_index = GetIndexOfCombiningFirstCode( |
first_code_index = UnicodeGetIndexOfCombiningFirstCode(code); |
| 6032 |
code, mapCombiningToPrecomposed, MAPSIZE(mapCombiningToPrecomposed) |
if (first_code_index != -1) { |
|
)) != -1) { |
|
|
|
|
| 6033 |
// 1つめの文字はそのまま出力する |
// 1つめの文字はそのまま出力する |
| 6034 |
UnicodeToCP932(first_code); |
UnicodeToCP932(first_code); |
| 6035 |
|
|