本文整理自网络,侵删。
//机内码 -> 汉字Function MacCode2Chinese(AiUniCode : Integer) : String;Varch, cl : Integer;Begin ch := AiUniCode Div 256; cl := AiUniCode Mod 256; Result := C=h=r(ch) + C=h=r(cl); //C=h=r 把这个编程 Chrend;
//汉字 -> 机内码Function Chinese2MacCode(AiChinese : String) : Integer;Varch, cl : Integer;Begin ch := Ord(AiChinese[1]); cl := Ord(AiChinese[2]); Result := (ch shl 8) + cl;end;
//UniCode -> 汉字Function UniCode2Chinese(AiUniCode : Integer) : String;Varch, cl : String[3];s : String;Begin s := IntToHex(AiUniCode, 2); cl := '$' + Copy(s, 1, 2); ch := '$' + Copy(s, 3, 2); s := C=h=r(StrToInt(ch)) + C=h=r(StrToInt(cl)) + #0; //C=h=r 把这个编程 Chr Result := WideCharToString(pWideChar(s));end;
//汉字 -> UniCodeFunction Chinese2UniCode(AiChinese : String) : Integer;Varch, cl : String[2];a : array [1..2] of char;Begin StringToWideChar(Copy(AiChinese, 1, 2), @(a[1]), 2); ch := IntToHex(Integer(a[2]), 2); cl := IntToHex(Integer(a[1]), 2); Result := StrToInt('$' + ch + cl);end;
相关阅读 >>
Delphi显示 jpg、png、gif 图片及 gif 动画
Delphi windows 编程[11] - wm_size 消息
更多相关阅读请进入《Delphi》频道 >>