luckyluke Posted October 12, 2008 Posted October 12, 2008 (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 October 12, 2008 by luckyluke
LarryDalooza Posted October 12, 2008 Posted October 12, 2008 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 AutoIt has helped make me wealthy
luckyluke Posted October 12, 2008 Author Posted October 12, 2008 how to convert string to Unicode UFT-8???
rover Posted October 12, 2008 Posted October 12, 2008 $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. 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...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now