|
Overview |
|
|
|
Group |
|
|
|
Quick Info
Windows NT
| Yes
| Win95
| Yes
| Win32s
| Yes
| Import Library
| kernel32.lib
| Header File
| winnls.h
| Unicode
| No
| Platform Notes
| None
|
|
|
MultiByteToWideChar
The MultiByteToWideChar function maps a character string to a wide-character (Unicode) string. The
character string mapped by this function is not necessarily from a multibyte
character set.
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
| );
|
|
Parameters
CodePage
Specifies the code page to be used to perform the conversion. This parameter
can be given the value of any codepage that is installed or available in the
system. The following values may be used to specify one of the system default code
pages:
Value
| Meaning
| CP_ACP
| ANSI code page
| CP_MACCP
| Macintosh code page
| CP_OEMCP
| OEM code page
|
dwFlags
A set of bit flags that indicate whether to translate to precomposed or
composite wide characters (if a composite form exists), whether to use glyph
characters in place of control characters, and how to deal with invalid characters. You
can specify a combination of the following flag constants:
Value
| Meaning
| MB_PRECOMPOSED
| Always use precomposed characters that is, characters in which a base character and a nonspacing character have
a single character value. This is the default translation option. Cannot be
used with MB_COMPOSITE.
| MB_COMPOSITE
| Always use composite characters that is, characters in which a base character and a nonspacing character have
different character values. Cannot be used with MB_PRECOMPOSED.
| MB_ERR_INVALID_CHARS
| If the function encounters an invalid input character, it fails and GetLastError returns ERROR_NO_UNICODE_TRANSLATION.
| MB_USEGLYPHCHARS
| Use glyph characters instead of control characters.
|
A composite character consists of a base character and a nonspacing character,
each having different character values. A precomposed character has a single
character value for a base/non-spacing character combination. In the character è, the e is the base character and the accent grave mark is the nonspacing character.
The function's default behavior is to translate to the precomposed form. If a
precomposed form does not exist, the function attempts to translate to a
composite form.
The flags MB_PRECOMPOSED and MB_COMPOSITE are mutually exclusive. The
MB_USEGLYPHCHARS flag and the MB_ERR_INVALID_CHARS can be set regardless of the state
of the other flags.
lpMultiByteStr
Points to the character string to be converted.
cchMultiByte
Specifies the size in bytes of the string pointed to by the lpMultiByteStr parameter. If this value is 1, the string is assumed to be null terminated and the length is calculated
automatically.
lpWideCharStr
Points to a buffer that receives the translated string.
cchWideChar
Specifies the size, in wide characters, of the buffer pointed to by the lpWideCharStr parameter. If this value is zero, the function returns the required buffer
size, in wide characters, and makes no use of the lpWideCharStr buffer.
Return Values
If the function succeeds, and cchWideChar is nonzero, the return value is the number of wide characters written to the
buffer pointed to by lpWideCharStr.
If the function succeeds, and cchWideChar is zero, the return value is the required size, in wide characters, for a
buffer that can receive the translated string.
If the function fails, the return value is zero. To get extended error
information, call GetLastError. GetLastError may return one of the following error codes:
ERROR_INSUFFICIENT_BUFFER
| ERROR_INVALID_FLAGS
| ERROR_INVALID_PARAMETER
| ERROR_NO_UNICODE_TRANSLATION
|
Remarks
The lpMultiByteStr and lpWideCharStr pointers must not be the same. If they are the same, the function fails, and GetLastError returns the value ERROR_INVALID_PARAMETER.
The function fails if MB_ERR_INVALID_CHARS is set and it encounters an invalid
character in the source string. An invalid character is one that would
translate to the default character if MB_ERR_INVALID_CHARS was not set, but is not
the default character in the source string, or when a lead byte is found in a
string and there is no valid trail byte for DBCS strings. When an invalid
character is found, and MB_ERR_INVALID_CHARS is set, the function returns 0 and sets GetLastError with the error ERROR_NO_UNICODE_TRANSLATION.
See Also
WideCharToMultiByte
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|