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

convert string into ANSI from UTF-8/Unicode

$
0
0
I have a need to convert a unicode string into the appropriate ANSI encoding.
Purpose is to insert the ANSI string into an old application, which with proper encoding selected, displays the same character.

This seems like a simple job.

I have the following:
[ autoit ]      
#include  <WinAPI.au3> $string = "שָׁלוֹם"   ; shalom in Hebrew $out = _WinAPI_WideCharToMultiByte($string) ConsoleWrite($out & @CRLF )

My expected outcome is (using my default ANSI, Western Europe codepage):
ùÈÑìåÉí

which when encoded in Win1255 ("Hebrew") correctly displays שָׁלוֹם.

Problem is that I can ONLY get question marks, or empty string, no matter when I put as parameter for the WideChartoMultiByte...

What am I missing here ?

How can I tell the WideCharToMultiByte function which encoding I would like ?
So far I am looking for
UTF8 ==> GBK (or GB2312) for Chinese/Simplified
UTF8==> ANSI (Hebres, Win1255)
UTF8==> KoreanJohab

I can't be the only person ever to do this ?

The conversion works perfectly using sofware such as "Charco" (freeware), but I would love to have this natively in my script.

Viewing all articles
Browse latest Browse all 12506

Trending Articles



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