取漢字的機內碼、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;
http://i.mop.com/caibao35/blog
//漢字 -> 機內碼
Function Chinese2MacCode(AiChinese : String) : Integer;
Var
  ch, cl : Integer;
Begin
  ch := Ord(AiChinese[1]);
  cl := Ord(AiChinese[2]);
  Result := (ch shl 8) + cl;
end;
50b2679b565acb70b30a07fb539c09d7
//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;  

 虹口區 黃浦區 金山區 盧灣區 松江區 寶山區 南市區 長寧區 閘北區 浦東新區 嘉定區 楊浦區 普陀區 青浦縣 閔行區 徐彙區 崇明縣 靜安區 奉賢縣
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章