Converts a UTF-16 (wide character) string to a multibyte string
#include <WinAPIConv.au3>
_WinAPI_WideCharToMultiByte ( $vUnicode [, $iCodePage = 0 [, $bRetNoStruct = True [, $bRetBinary = False]]] )
$vUnicode | String, DllStruct or Pointer to a byte array structure containing Unicode text to be converted |
$iCodePage | [optional] Code page to use in performing the conversion: 0 - The current system Windows ANSI code page 1 - The current system OEM code page 2 - The current system Macintosh code page 3 - The Windows ANSI code page for the current thread 42 - Symbol code page 65000 - UTF-7 65001 - UTF-8 |
$bRetNoStruct | [optional] Flags that indicate whether to return a String/Binary or a DllStruct (default True : String/Binary) |
$bRetBinary | [optional] Flags that indicate whether to return a Binary String or a String (default False : String) |
Success: | A string/binary or a DllStruct containing a multibyte string/binary. |
Failure: | Sets the @error flag to non-zero, call _WinAPI_GetLastError() to get extended error information. |
Maps a UTF-16 (wide character) string to a new character string.
The new character string is not necessarily from a multibyte character set.
The $bRetBinary flag is designed for users of multi-byte codepages and forces the function to return a 0-terminated binary string or a struct containing it depending on $bRetNoStruct.
The $bRetNoStruct flag determines if the function should return only the string/binary or the entire struct.
Search WideCharToMultiByte in MSDN Library.
#include <WinAPIConv.au3>
Global Const $CP_SHIFT_JIS = 932
Local $sTest
Local $sText = "データのダウンロードに失敗しました。"
$sTest = _WinAPI_WideCharToMultiByte($sText, $CP_SHIFT_JIS, True, False)
MsgBox($MB_SYSTEMMODAL, "Title Sring",$sText & @CRLF & VarGetType($sTest) & " " & StringLen($sTest) & ": '" & $sTest & "'")
$sTest = _WinAPI_WideCharToMultiByte($sText, $CP_SHIFT_JIS, True, True)
MsgBox($MB_SYSTEMMODAL, "Title Binary",$sText & @CRLF & VarGetType($sTest) & " " & StringLen($sTest) & ": '" & $sTest & "'")