WinAPI字符及字符串函数(14):CharToOem、OemToChar
CharToOemBuff和OemToCharBuff与CharToOem和OemToChar的区别仅在于前者可以指定要转换的字符数。unit Unit1
接口
使用
窗口、消息、系统工具、变体、类、图形、控件、表单、
对话框、StdCtrls
type
t form 1 = class(t form)
button 1:t button;
button 2:t button;
button 3:t button;
button 4:t button;
过程按钮1Click(发件人:to object);
过程按钮2 click(Sender:to object);
过程button 4 click(Sender:to object);
过程按钮3 click(Sender:to object);
end;var
form 1:t form 1;
实现
{$R *。dfm }程序TForm1。Button1Click(发件人:to object);var
Buf:PWideChar;
AnsiBuf: array[0..255]的AnsiChar
begin
Buf:= ' Delphi blog in case ';
CharToOem(Buf,ansi Buf);
show message(string(ansi buf));{ Delphi blog in case }
fill char(ANSI BUF,length (ANSI BUF),# 0);
CharToOemBuff(Buf,AnsiBuf,6);
show message(string(ansi buf));{在De的情况下}
end;程序TForm1。Button2Click(发送方:to object);var
str:string;
p:pansi char;
begin
str:= ' Delphi blog in case ';
p:= GetMemory(256);
CharToOem(PChar(str),p);
show message(string(p));{ Delphi blog in case }
free memory(p);
p:= GetMemory(256);
CharToOemBuff(PChar(str),p,6);
show message(string(p));{在De的情况下}
free memory(p);
end;程序TForm1。Button3Click(发送方:to object);var
ansi buf:pansi char;
Buf: array[0..255]的Char
begin
ansi buf:= ' Delphi blog in case ';
OemToChar(AnsiBuf,buf);
show message(string(Buf));{ Delphi blog in case }
fill char(BUF,length (BUF),# 0);
OemToCharBuff(AnsiBuf,Buf,6);
show message(string(Buf));{以防万一}
end;程序TForm1。Button4Click(发送方:to object);var
ansi string:ansi string;
p:PChar;
begin
ansi rst:= ' Delphi blog in case ';
p:= StrAlloc(256);
OemToChar(pansi char(ansi str),p);
show message(string(p));{ Delphi blog in case }
str dipose(p);
p:= StrAlloc(256);
OemToCharBuff(pansi char(ansi str),p,6);
show message(string(p));{以防万一}
str dipose(p);
end;
结束。
0条评论