vb中有asc函数是得到字符或汉字Ascii的,在delphi中却找不到有转换汉字ascii码的
函数,自己搞了一个,不到之处请大家多指教。function GetAsc(Str:string):String;
var
p:PByte;
Asc:string;
S:String;
SS:String;
begin
p:= pointer(Str);
Asc:=InttoHex(byte(p^),2);
SS:= '$'+Asc;
if Strtoint(SS)<=127 then
Result:= Asc
else
begin
S:= Asc ;
inc(p);
Asc:= inttoHex(Byte(p^),2);
S:= S+Asc;
Result:= s;
end;
end;
函数,自己搞了一个,不到之处请大家多指教。function GetAsc(Str:string):String;
var
p:PByte;
Asc:string;
S:String;
SS:String;
begin
p:= pointer(Str);
Asc:=InttoHex(byte(p^),2);
SS:= '$'+Asc;
if Strtoint(SS)<=127 then
Result:= Asc
else
begin
S:= Asc ;
inc(p);
Asc:= inttoHex(Byte(p^),2);
S:= S+Asc;
Result:= s;
end;
end;
解决方案 »
- delphi中comport控件接收问题
- 有谁做过Apache Shared Modules,我用delphi7开发的so,用apache2.2.4加载会导致appache无法启动
- imageList
- 请问ADOQury.edit有啥用?
- webservices 中连接数据库(oracle9i)
- 请问如何在只读介质(光盘)上设计有数据库查询软件!
- 打印控制码直接端口打印,请问如何改变字体(瘦长型的宋体)?
- 高难度的问题,请大家指教
- ★★★★★高难度问题:怎样取得一个类中函数或过程在内存中的地址?★★★★★
- 数据库连接,一个奇怪的问题。
- 在WebSnap技术中,我制作了一个按纽,使它没按一次,数据记录指针向下跳一下,可我的按纽却无论按多少下,就是第二条记录,请高手帮忙。
- 如何在DBGrid最后一条记录后插入一行空行!!高分求救世主100。
{ 如表示汉字“国”的是ASCII(b9)和ASCII(fa),这里是十六进制; }
以下为程序:
const
BufSize = 2000; { 串的最大容量 }type
TBuffer = array [1..BufSize] of Char; { 串缓存 }
TFileOfChar = file of Char; { 字符类型文件 }
{ 汉字字符类型 } TChnChar = string[2];var
Form1: TForm1;
implementation{$R *.dfm}
function ChnCharToRTFCode(Ch: TChnChar): string;
var
C1, C2: Char;
O1, O2: Byte;
S: string;
begin
C1 := Ch[1];
C2 := Ch[2];
O1 := Ord(C1);
O2 := Ord(C2);
S := Format('%2X', [O1]) + Format('%2X', [O2]);
Result := Lowercase(S);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
edit1.Text:= ChnCharToRTFCode('国');
end;
运行结果:b9fa
s1:string;
s2:string;
begin
s1:='国';
s2:=inttohex(ord(s1[1]),2)+inttohex(ord(s1[2]),2);
showmessage(s2)end;