汉字与 Unicode 转换 //转换 function Str_Gb2UniCode(text: string): String; var i,len: Integer; cur: Integer;
来源:互联网 发布:男士衣服搭配 知乎 编辑:程序博客网 时间:2024/06/06 01:34
汉字与 Unicode 转换
//转换
function Str_Gb2UniCode(text: string): String;
var
i,len: Integer;
cur: Integer;
t: String;
ws: WideString;
begin
Result := '';
ws := text;
len := Length(ws);
i := 1;
while i <= len do
begin
cur := Ord(ws[i]);
FmtStr(t,'%4.4X',[cur]);
Result := Result + t;
Inc(i);
end;
end;
//恢复
function Unicode_str(text: string):string;
var
i,len: Integer;
ws: WideString;
begin
ws := '';
i := 1;
len := Length(text);
while i < len do
begin
ws := ws + Widechar(StrToInt('$' + Copy(text,i,4)));
i := i+4;
end;
Result := ws;
end;
//测试
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(Str_Gb2UniCode('万一')); //4E074E00
ShowMessage(Unicode_str('4E074E00')); //万一
end;
引用万一博客
//转换
function Str_Gb2UniCode(text: string): String;
var
i,len: Integer;
cur: Integer;
t: String;
ws: WideString;
begin
Result := '';
ws := text;
len := Length(ws);
i := 1;
while i <= len do
begin
cur := Ord(ws[i]);
FmtStr(t,'%4.4X',[cur]);
Result := Result + t;
Inc(i);
end;
end;
//恢复
function Unicode_str(text: string):string;
var
i,len: Integer;
ws: WideString;
begin
ws := '';
i := 1;
len := Length(text);
while i < len do
begin
ws := ws + Widechar(StrToInt('$' + Copy(text,i,4)));
i := i+4;
end;
Result := ws;
end;
//测试
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(Str_Gb2UniCode('万一')); //4E074E00
ShowMessage(Unicode_str('4E074E00')); //万一
end;
引用万一博客
阅读全文
0 0
- 汉字与 Unicode 转换 //转换 function Str_Gb2UniCode(text: string): String; var i,len: Integer; cur: Integer;
- String与Integer 之间的转换
- [leetcode]Reverse Integer(%、/、int与String转换)
- String转换与Integer面试题
- String类型与Integer类型的转换
- Integer,int,String相互转换
- Java中 键盘录入Scanner,String与 Integer数据类型转换
- String转换成Integer源码分析
- String转换成Integer源码分析
- java中String,Integer,int之间转换
- Java类型转换Integer int String
- String int Integer间的转换
- java 类型转换 Long double String Integer
- Java String,int,Integer,char 类型转换
- String、int、Integer之间的转换
- STRING INT INTEGER间的转换
- STRING INT INTEGER间的转换(ZZ)
- STRING INT INTEGER间的转换
- 【QT】表格控件+qt中没delete是否会内存泄漏
- JavaScript窗体Window.ShowModalDialog使用详解
- Android问题集3
- Java System参数获取
- Redis 事务(张高伟)
- 汉字与 Unicode 转换 //转换 function Str_Gb2UniCode(text: string): String; var i,len: Integer; cur: Integer;
- mysql集群 之 [ERROR] InnoDB: Unable to lock ./ibdata1, error: 11
- linux下java环境的搭建
- Jquery单引号和双引号的使用注意
- eclipse的异常断点和条件断点设置方式
- protocol buffer 常用API
- system类
- 从零开始学习音视频编程技术(30) Linux篇之系统安装
- 获取某段时间内的小时、日期、月份,存储过程中使用的较多。