有个两个变量
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 去实现???

解决方案 »

  1.   

    转载我也没用过
    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字符串占用的内存块。
      

  2.   

    详细信息到MSDN上看
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/intl/unicode_2bj9.asp
      

  3.   

    var
    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);
      

  4.   

    自己看看delphi这个函数的源代码:
    function WideCharToString(Source: PWideChar): string;