MultiByteToWideChar() Codepages CP_ACP/CP_OEMCP

source:http://support.microsoft.com/?scid=kb%3Ben-us%3B108450&x=11&y=12

 

MultiByteToWideChar() Codepages CP_ACP/CP_OEMCP

<script type="text/javascript">if (!loadTOCNode) {var loadTOCNode = function(){}}</script>

This article was previously published under Q108450
Expand all | Collapse all <script type="text/javascript"> if (kb_page_object) { kb_page_object.kb_imageExpandHoverText = 'Click to expand this image'; } </script>

SUMMARY
MultiByteToWideChar() maps a character string to a wide-character string. The d...

<script type="text/javascript"> loadTOCNode(1, 'summary'); </script>
MultiByteToWideChar() maps a character string to a wide-character string. The declaration of this application programming interface (API) is as follows:
   int MultiByteToWideChar(uCodePage, dwFlags, lpMultiByteStr,
cchMultiByte, lpWideCharStr, cchWideChar)

UINT uCodePage; /* codepage */
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 wide-character buffer */
The first parameter, uCodePage, specifies the codepage to be used when performing the conversion. This discussion applies to the first parameter of WideCharToMultiByte() as well. The codepage can be any valid codepage number. It is a good idea to check this number with IsValidCodepage(), even though MultiByteToWideChar() returns an error if an invalid codepage is used. The codepage may also be one of the following values:
   CP_ACP       ANSI codepage
CP_OEMCP OEM (original equipment manufacturer) codepage
CP_ACP instructs the API to use the currently set default Windows ANSI codepage. CP_OEMCP instructs the API to use the currently set default OEM codepage.

If Win32 ANSI APIs are used to get filenames from a Windows NT system, use CP_ACP when converting the string. Windows NT retrieves the name from the physical device and translates the OEM name into Unicode. The Unicode name is translated into ANSI if an ANSI API is called, then it can be translated back into Unicode with MultiByteToWideChar().

If filenames are being retrieved from a file that is OEM encoded, use CP_OEMCP instead.

MORE INFORMATION
When an application calls an ANSI function, the FAT/HPFS file systems will call...

<script type="text/javascript"> loadTOCNode(1, 'moreinformation'); </script>
When an application calls an ANSI function, the FAT/HPFS file systems will call AnsiToOem(); however, if an ANSI character does not exist in an OEM codepage, the filename will not be representable. In these cases, SetFileApisToOEM() should be called to prevent this problem by setting a group of the Win32 APIs to use the OEM codepage instead of the ANSI codepage.

APPLIES TO
  • Microsoft Platform Software Development Kit-January 2000 Edition
  • Microsoft Win32 Software Development Kit (SDK) for Windows NT 3.5
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值