Hiho Forum
,
I'm looking for a way to reverse the byte order of a string (for UTF16-LE <> UTF16-BE transformation). I've found the function LCMapString which should imho do the trick, but can't get it to work correctly. Maybe one of the real pros want to take a look
...
Edit:
Sorry, much too complicated... this already does the trick
...
![:)](http://aut1.autoit-cdn.com/forum/public/style_emoticons/default/smile.png)
I'm looking for a way to reverse the byte order of a string (for UTF16-LE <> UTF16-BE transformation). I've found the function LCMapString which should imho do the trick, but can't get it to work correctly. Maybe one of the real pros want to take a look
![:whistle:](http://aut1.autoit-cdn.com/forum/public/style_emoticons/default/whistle.gif)
Edit:
Sorry, much too complicated... this already does the trick
![>_<](http://aut1.autoit-cdn.com/forum/public/style_emoticons/default/pinch.gif)
[ autoit ]
$in = "test22" ConsoleWrite(StringToBinary($in, 2) & @CRLF) ConsoleWrite(StringToBinary($in, 3) & @CRLF)
[ autoit ]
; LCMapString function ; http://msdn.microsoft.com/en-us/library/dd318700 $in = "test22" $t_in = DllStructCreate("wchar[" & StringLen($in) & "]") DllStructSetData($t_in, 1, $in) ConsoleWrite(StringToBinary(DllStructGetData($t_in, 1)) & @CRLF) $t_out = DllStructCreate("wchar[" & StringLen($in) & "]") ; LCMAP_BYTEREV := 0x800 $iRes = DllCall("kernel32.dll", "int", "LCMapStringW", "uint", 0, "dword", 0x800, "struct*", $t_in, "int", StringLen($in), "ptr", DllStructGetPtr($t_out), "int", StringLen($in)) ConsoleWrite($iRes[0] & @CRLF & $iRes[5] & @CRLF & $iRes[6] & @CRLF) ConsoleWrite(DllStructCreate("wchar[" & $iRes[6] & "]", $iRes[5]) & @CRLF & @CRLF) ConsoleWrite(StringToBinary(DllStructGetData($t_in, 1)) & @CRLF) ConsoleWrite(StringToBinary(DllStructGetData($t_out, 1)) & @CRLF)