unicode轉換FUNCTION~ |
|
huwk
資深會員 發表:26 回覆:340 積分:323 註冊:2002-04-03 發送簡訊給我 |
作者 Alfred Li
function Big5ToUnicode(const Ws: string; Page:Word):widestring; var IL,OL: Integer; begin IL :=Length(WS); OL :=MultiByteToWideChar(CodePage,0, Pchar(ws),IL,nil,0); SetLength(Result,OL); MultiByteToWideChar(CodePage,0, Pchar(ws),IL, pwidechar(Result),OL); end; // ANSI 轉 Unicode function StringToWideString(const S: string; CodePage: Word): WideString; var InputLength, OutputLength: Integer; begin InputLength := Length(S); OutputLength := MultiByteToWideChar(CodePage, 0, PChar(S), InputLength, nil, 0); SetLength(Result, OutputLength); MultiByteToWideChar(CodePage, 0, PChar(S), InputLength, PWideChar(Result), OutputLength); end; //Unicode 轉 ANSI function WideStringToString(const WS: WideString; CodePage: Word): string; var InputLength, OutputLength: Integer; begin InputLength := Length(WS); OutputLength := WideCharToMultiByte(CodePage, 0, PWideChar(WS), InputLength, nil, 0, nil, nil); SetLength(Result, OutputLength); WideCharToMultiByte(CodePage, 0, PWideChar(WS), InputLength, PChar(Result), OutputLength, nil, nil); end;
------
熊的學習 http://huwk.blogspot.com |
yanik
一般會員 發表:0 回覆:1 積分:0 註冊:2003-05-28 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |