Kernel32MultiByteToWideChar(UInt32, MultiByteCharConversionType, Byte, Int32, Char, Int32) Method
Maps a character string to a UTF-16 (wide character) string.
The character string is not necessarily from a multibyte character set.
Caution: Using the
MultiByteToWideChar(CodePage, MultiByteCharConversionType, Byte, Int32, Char, Int32) function incorrectly can compromise the
security of your application.
Calling this function can easily cause a buffer overrun because the size of the input buffer indicated by
multiByteStr equals the number of bytes in the string,
while the size of the output buffer indicated by
wideCharStr equals the number of characters.
To avoid a buffer overrun, your application must specify a buffer size appropriate for the
data type the buffer receives.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static int MultiByteToWideChar(
uint codePage,
MultiByteCharConversionType flags,
byte[] multiByteStr,
int multiByteStrSize,
char[] wideCharStr,
int wideCharStrSize
)
<DllImportAttribute("Kernel32.dll", CharSet := CharSet.Unicode, SetLastError := true>]
Public Shared Function MultiByteToWideChar (
codePage As UInteger,
flags As MultiByteCharConversionType,
multiByteStr As Byte(),
multiByteStrSize As Integer,
wideCharStr As Char(),
wideCharStrSize As Integer
) As Integer
Dim codePage As UInteger
Dim flags As MultiByteCharConversionType
Dim multiByteStr As Byte()
Dim multiByteStrSize As Integer
Dim wideCharStr As Char()
Dim wideCharStrSize As Integer
Dim returnValue As Integer
returnValue = Kernel32.MultiByteToWideChar(codePage,
flags, multiByteStr, multiByteStrSize,
wideCharStr, wideCharStrSize)
public:
[DllImportAttribute(L"Kernel32.dll", CharSet = CharSet::Unicode, SetLastError = true)]
static int MultiByteToWideChar(
unsigned int codePage,
MultiByteCharConversionType flags,
array<unsigned char>^ multiByteStr,
int multiByteStrSize,
array<wchar_t>^ wideCharStr,
int wideCharStrSize
)
[<DllImportAttribute("Kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)>]
static member MultiByteToWideChar :
codePage : uint32 *
flags : MultiByteCharConversionType *
multiByteStr : byte[] *
multiByteStrSize : int *
wideCharStr : char[] *
wideCharStrSize : int -> int
No code example is currently available or this language may not be supported.
- codePage UInt32
-
Code page to use in performing the conversion.
This parameter can be set to the value of any code page that is installed or available in the operating system.
- flags MultiByteCharConversionType
-
Flags indicating the conversion type.
- multiByteStr Byte
-
Pointer to the character string to convert.
- multiByteStrSize Int32
-
Size, in bytes, of the string indicated by the multiByteStr parameter.
Alternatively, this parameter can be set to -1 if the string is null-terminated.
Note that, if multiByteStrSize is 0, the function fails.
If this parameter is -1, the function processes the entire input string, including the terminating null character.
Therefore, the resulting Unicode string has a terminating null character,
and the length returned by the function includes this character.
If this parameter is set to a positive integer, the function processes exactly the specified number of bytes.
If the provided size does not include a terminating null character, the resulting Unicode string is not null-terminated,
and the returned length does not include this character.
- wideCharStr Char
-
Pointer to a buffer that receives the converted string.
- wideCharStrSize Int32
-
Size, in characters, of the buffer indicated by wideCharStr.
If this value is 0, the function returns the required buffer size, in characters,
including any terminating null character, and makes no use of the wideCharStr buffer.
Int32
Returns the number of characters written to the buffer indicated by
wideCharStr if successful.
If the function succeeds and
wideCharStrSize is 0, the return value is the required size,
in characters, for the buffer indicated by
wideCharStr.
The function returns 0 if it does not succeed.