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;

相关文章:

  • 2021-12-10
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2021-11-09
  • 2021-11-09
猜你喜欢
  • 2021-11-09
  • 2022-03-07
  • 2022-02-03
  • 2022-12-23
相关资源
相似解决方案