delphi String转Unicode


本文整理自网络,侵删。

 unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
function StrtoUnicode(Str:string):string;
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}
function TForm1.StrtoUnicode(Str:string):string;
var
s:string;
i,j,k:Integer;
a:array [1..1000] of Char;
begin
s:='';
StringToWideChar(Str,@(a[1]),500);
i:=1;
while ((a[i]<>#0) or (a[i+1]<>#0)) do
begin
j:=Integer(a[i]);
k:=Integer(a[i+1]);
s:=s+copy(Format('%X',[k*$100+j+$10000]),2,4);
i:=i+2;
end;
Result:=s;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
Edit2.Text:=StrtoUnicode(Edit1.Text);
end;

end.

相关阅读 >>

Delphi 无法打不开读取文件名有逗号的文件

Delphi取得cxgrid 合计数

Delphi之伪造referer下载文件

Delphi 5-7 桥接让Delphi xe2 datasnap中间层支持Delphi低版本开发客户端

Delphi sqlite incomplete input 错误

Delphi idhttp下载带清理网络缓存

Delphi中使用isuperobject解析json数据

Delphi 调用wmi信息判断系统师傅安装杀毒软件

Delphi eof 判断文件指针是否移动到了文件未尾

Delphi源码 基础源码-连接数据库,验证登录信息

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



打赏

取消

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

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

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

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

评论

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