WideCharToMultiByte 怎么用?

//参考如下代码

function UnicodeToMBCS( //将Unicode编码字符串转换成多字节字符串
  mCodePage: UINT; //对照表页码
  mUnicode: WideString //Unicode编码字符串
): string; //返回处理后的字符串
var
  L: Integer;
begin
  L := WideCharToMultiByte(
    mCodePage, 0, PWideChar(mUnicode), -1, nil, 0, nil, nil);
  SetLength(Result, L);
  if L <= 0 then Exit;
  WideCharToMultiByte(mCodePage, 0,
    PWideChar(mUnicode), -1, @Result[1], L, nil, nil);
end; { UnicodeToMBCS }

function MBCSToUnicode( //将多字节字符串转换成Unicode编码字符串
  mCodePage: UINT; //对照表页码
  mMBCS: string //多字节字符串
): WideString; //返回处理后的字符串
var
  L: Integer;
begin
  L := MultiByteToWideChar(mCodePage, 0, PChar(mMBCS), -1, nil, 0);
  SetLength(Result, L);
  if L <= 0 then Exit;
  MultiByteToWideChar(mCodePage, 0, PChar(mMBCS), -1, @Result[1], L);
end; { MBCSToUnicode }

出处:http://bbs.csdn.net/topics/110082252

posted @ 2013-07-31 19:33  stma  阅读(338)  评论(0)    收藏  举报