function DecodeWideString(Value:String):wideString;
var
I:Integer;
begin
Result:='';
for I:=0 to (Length(Value) div 4)-1 do begin
Result:=Result+wchar(strtoint('$'+value[I*4+1]+value[I*4+2])shl 8+strtoint('$'+Value[I*4+3]+Value[I*4+4]) );
end; end;
var
I:Integer;
begin
Result:='';
for I:=0 to (Length(Value) div 4)-1 do begin
Result:=Result+wchar(strtoint('$'+value[I*4+1]+value[I*4+2])shl 8+strtoint('$'+Value[I*4+3]+Value[I*4+4]) );
end; end;
解决方案 »
- 求一个逆算法的代码
- 怎样通过文件名排序和修改时间排序确定某目录下最新的文件名
- combobox如何设置默认项?
- 数据过滤问题
- 在下愿意高分讨教:数据库BDE问题!
- TAB控件怎么用啊
- 想用DELPHI做一个语音聊天室,不知道该用哪个方面的东西/不知道的兄弟也请帮我UP一下----200分今天晚上结!!!!!!!贴
- 欢迎大家下载我的软件,下载者有分.
- 一个关于数据库的问题,分都不要了。
- 高手请进,我现在想做一个程序,可以Down下我们班级在同学录上面的留言,
- 如何将已query查出的结果在两个dbgrid中关联显示??
- 一个简单的问题。不过我不会。怎样用WINEXEC函数。怎样调用期它应用程序比如WORD?
ShowMessage(Format('%8.8x', [3465243]));
用Format转换就可以了.
//encode the widestring to saveable string
//2003.03.04
var
I:Integer;
begin
Result:='';
for I:=1 to Length(Value) do begin
Result:=Result+IntToHex(WORD(Value[I]) shr 8,2);
Result:=Result+IntToHex(WORD(Value[I]) and $00ff,2);
end;
end;function DecodeWideString(Value:String):WideString;
//decode the string to widestring
//2003.03.04
var
I:Integer;
begin
Result:='';
for I:=0 to (Length(Value) div 4)-1 do begin
Result:=Result+WChar(StrToInt('$'+Value[I*4+1]+Value[I*4+2]) shl 8
+ StrToInt('$'+Value[I*4+3]+Value[I*4+4]));
end;
end;function EncodeUnicodeSQL(Value:WideString):String;
//encode the widestring to string of unicode ascii set
//be used for search unicode char in SQL server
//2003.03.21
var
I:Integer;
begin
Result:='';
for I:=1 to Length(Value) do begin
if I>1 then begin
Result:=Result+'+';
end;
Result:=Result+'NCHAR('+IntToStr(Word(Value[I]))+')';
end;
end;我用很正常啊,你先用EncodeWideString()将中文转成普通字符串,看看和你要使用的格式是否一样。
var
i:Integer;
s:string;
begin
for I:=0 to (Length(Value) div 4)-1 do
begin
s:=Copy(Value,i*4+1,4);
Result:=Result+widechar(StrToInt('$'+s));
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
const
s:WideString='中国人';
begin
caption:=DecodeWideString(inttohex(ord(s[1]),4)+InttoHex(Ord(s[2]),4));
end;