Sign in to follow this  
Followers 0
luckyluke

what i am missing ? (_WinAPI_WideCharToMultiByte )

4 posts in this topic

#1 ·  Posted (edited)

$String = "ChÆ°a Äủ Bá»™"
$s = _WinAPI_MultiByteToWideChar($String, 65001)
MsgBox(0, "", $s)

I want to convert $String to UTF-8 encoding, but nothing happen, plz help

Edited by luckyluke

Share this post


Link to post
Share on other sites



65001 does not appear to be an option...

; Name...........: _WinAPI_MultiByteToWideChar
; Description ...: Maps a character string to a wide-character (Unicode) string
; Syntax.........: _WinAPI_MultiByteToWideChar($sText[, $iCodePage = 0[, $iFlags = 0]])
; Parameters ....: $sText       - Text to be converted
;                  $iCodePage   - Specifies the code page to be used to perform the conversion:
;                  |0 - ANSI code page
;                  |1 - OEM code page
;                  |2 - Macintosh code page
;                  $iFlags      - Flags that indicate whether to translate to precomposed or composite wide characters:
;                  |$MB_PRECOMPOSED   - Always use precomposed characters
;                  |$MB_COMPOSITE     - Always use composite characters
;                  |$MB_USEGLYPHCHARS - Use glyph characters instead of control characters

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Share this post


Link to post
Share on other sites

how to convert string to Unicode UFT-8???

Share this post


Link to post
Share on other sites

$String = "ChÆ°a Äủ Bá»"
$s = _WinAPI_MultiByteToWideChar($String, 65001)
MsgBox(0, "", $s)

I want to convert $String to UTF-8 encoding, but nothing happen, plz help

@luckyluke

MSDN is your friend. :P

MultiByteToWideChar CP_UTF8 - MSDN Search

http://social.msdn.microsoft.com/Search/en...P_UTF8&ac=3

MSDN - MultiByteToWideChar

http://msdn.microsoft.com/en-us/library/ms776413(VS.85).aspx

above link says UTF-8 supported

Note: For UTF-8, dwFlags must be set to either 0 or MB_ERR_INVALID_CHARS.

Otherwise, the function fails with ERROR_INVALID_FLAGS.

Sorting it all Out : A few of the gotchas of MultiByteToWideChar

http://blogs.msdn.com/michkap/archive/2005/04/19/409566.aspx

_WinAPI_MultiByteToWideChar returns a struct

from help file:

Return Value

Success: Structure that contains the Unicode character string

#include <WinAPI.au3>
Global Const $CP_UTF8 = 65001

$String = "ChÆ°a Äủ Bá»"
$tS = _WinAPI_MultiByteToWideChar($String, $CP_UTF8) ;$iFlags default is 0

$s = DllStructGetData($tS, 1) ;struct is byte array, *char[n], byte[n] and ubyte[n] return all element data when index is omitted.

MsgBox(0, "", $s & @CRLF & _WinAPI_WideCharToMultiByte(DllStructGetPtr($tS)))

I see fascists...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0