网上一个帖子你参考一下.<br>http://topic.csdn.net/t/20040907/11/3347454.html<br>另附一段代码.主要调用WINDOWS的函数进行参照对比.<br><br>unit GBBIG5Cvt;<br><br>{$Define wt_Multilanguage_Flag}<br><br>interface<br><br>type<br> TWordConvertMethod = procedure (var S: String);<br><br><br>function GBToUnicode(const GBStr: String): WideString;<br>function UnicodeToGB(const WStr: WideString): String;<br><br>function Big5ToUnicode(const BIG5Str: String): WideString;<br>function UnicodeToBig5(const WStr: WideString): String;<br><br>function GBToBig5(const GBStr: String): String;<br>function Big5ToGB(const Big5Str: String): String;<br><br>procedure ClearWordConvertMetods;<br><br>var<br> WordConvert_Big5,<br> WordConvert_GB: TWordConvertMethod;<br><br>implementation<br><br>uses<br> Windows, SysUtils;<br><br>const<br> GBCodePage = 936;<br> Big5CodePage = 950;<br><br>type<br> TMyDWordRec = packed record<br> case Integer of<br> 0: (Value: DWORD);<br> 1: (Lo, Hi: Word);<br> end;<br><br>procedure ClearWordConvertMetods;<br>begin<br> WordConvert_Big5 := nil;<br> WordConvert_GB := nil;<br>end;<br><br><br>////////////////////////////////////////////////////////////////////////////////<br>//这几个都是VC中的宏定义,Delphi中没有所以自己写一下?<br>function MAKELCID(const wLanguageID, wSortID: Word): DWORD;<br>var<br> Rec: TMyDWordRec;<br>begin<br> Rec.Lo := wLanguageID;<br> Rec.Hi := wSortID;<br> Result := Rec.Value;<br>end;<br><br><br>function MAKELANGID(const usPrimaryLanguage, usSubLanguage: Word): Word;<br>begin<br> Result := Word((usSubLanguage shl 10)) or usPrimaryLanguage;<br>end;<br><br>{<br>function PRIMARYLANGID(lgid : Word) : Word;<br>begin<br> Result := lgid and $3FF;<br>end;<br><br>function SUBLANGID(lgid : Word) : DWord;<br>begin<br> Result := lgid shr 10;<br>end;<br>}<br>////////////////////////////////////////////////////////////////////////////////<br><br>function ChkErr(iVal: Integer): Integer;<br>begin<br> Result := iVal;<br> if Result = 0 then<br> RaiseLastOSError;<br>end;<br><br>function StrToUnicode(const S: String; const CodePage: DWord): WideString;<br>var<br> iLen: Integer;<br>begin<br> iLen := ChkErr(MultiByteToWideChar(CodePage, 0, PChar(S), -1, nil, 0));<br> SetLength(Result, iLen - 1);<br> ChkErr(MultiByteToWideChar(CodePage, 0, PChar(S), -1,<br> PWideChar(Result), iLen));<br>end;<br><br>function UnicodeToStr(const WStr: WideString; const CodePage: DWord): String;<br>var<br> iLen: Integer;<br>begin<br> iLen := ChkErr(WideCharToMultiByte(CodePage, 0,<br> PWChar(WStr), -1, nil, 0, nil, nil));<br> SetLength(Result, iLen - 1);<br> ChkErr(WideCharToMultiByte(CodePage, 0, PWChar(WStr), -1, PChar(Result), iLen,<br> nil, nil));<br>end;<br><br>function GBToUnicode(const GBStr: String): WideString;<br>begin<br> Result := StrToUnicode(GBStr, GBCodePage);<br>end;<br><br>function UnicodeToGB(const WStr: WideString): String;<br>begin<br> Result := UnicodeToStr(WStr, GBCodePage);<br>end;<br><br>function Big5ToUnicode(const BIG5Str: String): WideString;<br>begin<br> Result := StrToUnicode(BIG5Str, Big5CodePage);<br>end;<br><br>function UnicodeToBig5(const WStr: WideString): String;<br>begin<br> Result := UnicodeToStr(WStr, Big5CodePage);<br>end;<br><br>function Big5ToGB(const Big5Str: String): String;<br>var<br> Value: String;<br> iLen: Integer;<br> LocaleID: LCID;<br> S: String;<br>begin<br> if Big5Str = '' then<br> exit;<br><br> S := Big5Str;<br> if Assigned(WordConvert_Big5) then<br> WordConvert_Big5(S);<br><br> //内码的转换<br> Value := UnicodeToGB(Big5ToUnicode(S));<br><br> //简繁体转换在GB内码下做比较合适,好像简体中文内码中包含繁体字可以一一对应<br> //到Big5<br> LocaleID := MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED),<br> SORT_CHINESE_PRC);<br> iLen := ChkErr(LCMapString(LocaleID, LCMAP_SIMPLIFIED_CHINESE, PChar(Value),<br> -1, nil, 0));<br> SetLength(Result, iLen - 1);<br> ChkErr(LCMapString(LocaleID, LCMAP_SIMPLIFIED_CHINESE, PChar(Value), -1,<br> PChar(Result), iLen));<br>end;<br><br>function GBToBig5(const GBStr: String): String;<br>var<br> Value: String;<br> iLen: Integer;<br> LocaleID: LCID;<br> S: String;<br>begin<br> if GBStr = '' then<br> exit;<br><br> S := GBStr;<br><br> if Assigned(WordConvert_GB) then<br> WordConvert_GB(S);<br><br> //简繁体转化GB内码下做比较合适<br> LocaleID := MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED),<br> SORT_CHINESE_PRC);<br> iLen := ChkErr(LCMapString(LocaleID, LCMAP_TRADITIONAL_CHINESE, PChar(S),<br> -1, nil, 0));<br> SetLength(Value, iLen - 1);<br> ChkErr(LCMapString(LocaleID, LCMAP_TRADITIONAL_CHINESE, PChar(S), -1,<br> PChar(Value), iLen));<br> Result := UnicodeToBig5(GBToUnicode(Value));<br>end;<br><br>initialization<br> ClearWordConvertMetods;<br><br>finalization<br><br><br>end.