delphi返回一个汉字的Unicode编码


本文整理自网络,侵删。

 
//机内码 -> 汉字
Function MacCode2Chinese(AiUniCode : Integer) : String;
Var
ch, cl : Integer;
Begin
  ch := AiUniCode Div 256;
  cl := AiUniCode Mod 256;
  Result := C=h=r(ch) + C=h=r(cl);  //C=h=r 把这个编程 Chr
end;

//汉字 -> 机内码
Function Chinese2MacCode(AiChinese : String) : Integer;
Var
ch, cl : Integer;
Begin
  ch := Ord(AiChinese[1]);
  cl := Ord(AiChinese[2]);
  Result := (ch shl 8) + cl;
end;

//UniCode -> 汉字
Function UniCode2Chinese(AiUniCode : Integer) : String;
Var
ch, 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;

//汉字 -> UniCode
Function Chinese2UniCode(AiChinese : String) : Integer;
Var
ch, 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程序在每个windows 会话中只执行一次

Delphi中内嵌汇编

Delphi 获取打印机纸型的例子

Delphi access 导出 excel 表格

Delphi 如何读取文件头 判断文件类型

Delphi调用游戏call代码

Delphi 防止程序重复执行(多种方法)

Delphi用idtcpserver和idtcpclient传输文件

Delphi 获取ie7 ie8 ie9 地址栏网址

Delphi 如何从html格式的字符串中提取纯文本?

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...