如果GB和Big5在一个文本文件,很难分开GB范围:
1st byte 2nd byte
b0-ff a0-feBig5范围:
1st byte 2nd byte
a0-ff 40-7e or >a0判断方法如下:(转换代码可以问我要)function isBIG5(value: string): Boolean;
begin
if (length(value)>=2) then
begin
if (value[1] < #161) then
Result := false
else
if ((value[2] >= #64) and (value[2] <= #126)) or ((value[2] >= #161) and (value[2] <= #254)) then
Result := true
else
Result := false
end
else
Result := false
end;function isGB(value: string): Boolean;
begin
if (length(value)>=2) then
begin
if (value[1] <= #161) and (value[1] >= #247) then
Result := false
else
if (value[2] <= #161) and (value[2] >= #254) then
Result := false
else
Result := true
end
else
Result := true;
end;
1st byte 2nd byte
b0-ff a0-feBig5范围:
1st byte 2nd byte
a0-ff 40-7e or >a0判断方法如下:(转换代码可以问我要)function isBIG5(value: string): Boolean;
begin
if (length(value)>=2) then
begin
if (value[1] < #161) then
Result := false
else
if ((value[2] >= #64) and (value[2] <= #126)) or ((value[2] >= #161) and (value[2] <= #254)) then
Result := true
else
Result := false
end
else
Result := false
end;function isGB(value: string): Boolean;
begin
if (length(value)>=2) then
begin
if (value[1] <= #161) and (value[1] >= #247) then
Result := false
else
if (value[2] <= #161) and (value[2] >= #254) then
Result := false
else
Result := true
end
else
Result := true;
end;
WideCharToMultiByte和MultiByteToWideChar
来转换呢???
BIG5和GB汉字内码都是双字节的,用适当的统计可以区分。
两个系统的头一个字节都是大于0xa0的,如果第二个字节的取值范围在0x40至0xa0之间的内容,则应该是BIG5编码,否则如果全部汉字的第二个字节都是在0xa1至0xfe之间,则为GB编码。
1st byte 2nd byte
0x81~0xfe 0x40~0x7e and 0x80~0xfeBIG5范围:
1st byte 2nd byte
0x81~0xfe 0x40~0x7e and 0xa1~0xfeIsDBCSLeadByteEx()函数通过936和950无法准确判断可能此原因
但RichWin之类外挂中文平台如何做到?主要是转换问题:
一般可通过查表解决,
但在非中文NT上需要GB和BIG5两种ttf字库,
如通过类似VB的strconv()借unicode把BIG5转为GB,
则只需一个字库。
VC中LCMapString()是否作此用处?如何使用?还请指教!非常感谢!