试试这个: type TLanguage = (tNone,tEnglish,tGBChs,tBig5,tGBCht);
var Map: array[1..13468] of array[1..2] of integer;
function FindBig5(ACodeValue: Integer): string; var a, b, i, m, j: Integer; F: Boolean; c1, c2: Char; begin a := 0; b := 13468; i := (a + b) shr 1; F := False; m := 0; while not F do begin m := Map[i][1]; if ACodeValue = m then begin F := True; m := Map[i][2]; for j := i downto 0 do begin if Map[j][1] = ACodeValue then m := Map[j][2] else break; end;
Break; end else if ACodeValue > m then begin a := i + 1; end else begin b := i - 1; end;
i := (a + b) shr 1;
if a > b then Break; end; if not F then m := ACodeValue;
c1 := chr(m shr 8); c2 := chr(m mod 256);
Result := c1 + c2; end;
function L_(AChsStr: string): string; var i: Integer; c1, c2, c3: Integer; begin Result := ''; c2 := 0; for i := 1 to Length(AChsStr) do begin c1 := ord(AChsStr[i]); if c2 <> 0 then begin c3 := (c2 shl 8) + c1; Result := Result + FindBig5(c3); c2 := 0; end else if c1 >= 128 then begin c2 := c1; end else begin Result := Result + AChsStr[i]; end; end; end;
//获取操作系统默认语言 // -1、无效 0、英语 1、简体中文 3、繁体中文 function GetSysDefaultLg: TLanguage; var LangID: Integer; begin Result := tNone; LangID := GetSystemDefaultLangID; if LangID = ((SUBLANG_ENGLISH_US shl 10) or LANG_ENGLISH) then Result := tEnglish //美国英语 else if LangID = ((SUBLANG_CHINESE_SIMPLIFIED shl 10) or LANG_CHINESE) then Result := tGBChs //简体中文 else if LangID = ((SUBLANG_CHINESE_TRADITIONAL shl 10) or LANG_CHINESE) then Result := tBig5; //繁体中文 end;