通过数据线连接手机发送短信息中文,需要将中文转换成unicode编码
iptables 例如
你好
的unicode编码为
044F60597D
原理和如何编程实现转换?
---------------------------------------------------------------
其实你只要把你的字符串转化为widestring类型就可以了.
Type Maximum length Memory required Used for
ShortString 255 characters 2 to 256 bytes backward compatibility
AnsiString ~2^31 characters 4 bytes to 2GB 8-bit (ANSI) characters
WideString ~2^30 characters 4 bytes to 2GB Unicode characters;
---------------------------------------------------------------
var
WS: WideString;
WC: WideChar;
Code: Word;
begin
WS := '你好';
WC := WS[1];
Move(WC, Code, SizeOf(WC));
ShowMessage(IntToHex(Code, 2));
WC := WS[2];
Move(WC, Code, SizeOf(WC));
ShowMessage(IntToHex(Code, 2));
end;
var
I: Integer;
WS: WideString;
Code: Word;
Codes: String;
begin
WS := '你好';
Codes := '0x';
for I := 1 to Length(WS) do
begin
Move(WS[I], Code, SizeOf(Code));
Codes := Codes + IntToHex(Code, 2);
end;
ShowMessage(Codes);
end;
Delphi编程--将字符转换为unicode编码
最新推荐文章于 2024-09-22 09:08:30 发布