社區成員注意:同一主題下連續灌水回復3帖封ID,超過3帖封IP。詳細請看 [社区成员积分与等级制度]
社区成员积分与等级制度 常见的问题收集汇总 违规、恶意灌水处罚公告 版主、超级版主申请帖
     
1/1页1 跳转到查看:156
发新话题 回复该主题
1. 将鼠标移动到页面左上角待出现光标后,再慢慢移动到光标上,看帖更清爽
2. 键盘左右键可以进行前后翻页操作
帮助

[delphi]取汉字的机内码、UniCode码

[delphi]取汉字的机内码、UniCode码

//机内码 -> 汉字
Function MacCode2Chinese(AiUniCode : Integer) : String;
Var
  ch, cl : Integer;
Begin
  ch := AiUniCode Div 256;
  cl := AiUniCode Mod 256;
  Result := Chr(ch) + Chr(cl);
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 := Chr(StrToInt(ch)) + Chr(StrToInt(cl)) + #0;
  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;

TOP

 
1/1页1 跳转到
发表新主题 回复该主题