TA的每日心情 | 开心 2024-12-9 18:45 |
---|
签到天数: 124 天 [LV.7]常住居民III
|
欢迎您注册加入!这里有您将更精采!
您需要 登录 才可以下载或查看,没有账号?注册
x
简体中文与繁体中文的转换函数- function GB2Big(GB: string ): string;
- var
- Len: Integer;
- begin
- Len := Length(GB);
- SetLength(Result, Len);
- LCMapString(GetUserDefaultLCID, LCMAP_TRADITIONAL_CHINESE, PChar(GB), Len, PChar(Result), Len);
- end;
- function Big2GB(Big: string ): string;
- var
- Len: Integer;
- begin
- Len := Length(Big);
- SetLength(Result, Len);
- LCMapString(GetUserDefaultLCID, LCMAP_SIMPLIFIED_CHINESE, PChar(Big), Len, PChar(Result), Len);
- end;
复制代码 汉字与 Unicode 转换函数
{感谢 robin(xuebin418@163.com)提供}- //转换
- 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);
- 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;
复制代码 |
|