Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Reverse Byte Order of String (UTF16-LE <> UTF16-BE transformation)

$
0
0
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 :whistle:...

Edit:
Sorry, much too complicated... this already does the trick >_< ...

[ 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)

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>