有个两个变量
Msg_Content1:array [0..10 - 1] of CHAR
Msg_Content2:array [0..10 - 1] of CHARMsg_Content1的缓冲区内容是'0',''','Y','}',' ',#1,#0,#0,#0,#0 是unicode是“你好! ”我想用 WideCharToMultiByte 给他变成ascii码
应该是:#196,#227,#186,#195,#163,#161请高手指教怎么用WideCharToMultiByte 去实现???
Msg_Content1:array [0..10 - 1] of CHAR
Msg_Content2:array [0..10 - 1] of CHARMsg_Content1的缓冲区内容是'0',''','Y','}',' ',#1,#0,#0,#0,#0 是unicode是“你好! ”我想用 WideCharToMultiByte 给他变成ascii码
应该是:#196,#227,#186,#195,#163,#161请高手指教怎么用WideCharToMultiByte 去实现???
解决方案 »
- delphi实现摄像头拍照和摄像的问题
- TreeView中节点来自于ADOQuery1,如何才能使每个节点能保存对应的ADOQuery1.RecordNo 信息?
- 异常问题
- 请问FastReport如何显示预览界面??真急死我了。
- splash图片的静态与动态载入的问题
- RichEdit中的数据如何保存为一个文件中呀?马上给分!!
- 使用Filter时,怎样用字符串字段做条件?
- cancelbatch的问题?急!(在线等待)
- 50分求教:谁能给我讲一下FileCtrl的用法?
- 关于经验的问题?
- 大侠,救命呀!!!昨晚到两点半都没有搞对.关于INSERT语句.
- 【倒分投诉】请csdnlile和Iamanders解释
Windows函数MultiByteToWideChar用于将多字节字符串转换成宽字符串.int MultiByteToWideChar( UINT CodePage, // code page
DWORD dwFlags, // character-type options
LPCSTR lpMultiByteStr, // address of string to map
int cchMultiByte, // number of characters in string
LPWSTR lpWideCharStr, // address of wide-character buffer
int cchWideChar // size of buffer
);uCodePage参数用于标识一个与多字节字符串相关的代码页号。dwFlags参数用于设定另一个控件,
它可以用重音符号之类的区分标记来影响字符。这些标志通常并不使用,而在dwFlags参数
中则传递0。pMultiByteStr参数用于设定要转换的字符串,cchMultiByte参数用于指明
该字符串的长度(按字节计算)。如果你为cchMultiByte参数传递-1,那么该函数用于
确定源字符串的长度。转换后产生的Unicode版本字符串将被写入内存中的缓存,其地址
由pWideCharStr参数指定。你必须在cchWideChar参数中设定该缓存的最大值(以字符为
计量单位)。如果你调用MultiByteToWideChar,给cchWideChar参数传递0,那么该参数
将不执行字符串的转换,而是返回为使转换取得成功所需要的缓存的值。通过下列步骤
将多字节字符串转换成Unicode等价字符串:1. 调用MultiByteToWideChar函数,为pWideCharStr参数传递NULL,为cchWideChar
参数传递0。
2. 分配足够的内存块,用于存放转换后的Unicode字符串。该内存块的大小值由前面的对MultByteToWideChar的调用返回。
3. 再次调用MultiByteToWideChar,这次将缓存的地址作为pWideCharStr参数来传递,并传递第一次调用MultiByteToWideChar时返回的缓存大小值,作为cchWidechar参数。
4. 使用转换后的字符串。
5. 释放Unicode字符串占用的内存块。
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/unicode_2bj9.asp
s :string;
result: string;
count: integer;
begin
s := ...........
Count := Length(S);
SetLength(Result,Count+1);//
ZeroMemory(PChar(Result),Count+1);
WideCharToMultiByte(CP_ACP {FCodepage},0,PWideChar(S),Count,PChar(Result),Count,Nil,Nil);
function WideCharToString(Source: PWideChar): string;