Sign in to follow this  
Followers 0
TyroElite

UTF-8 to ANSI text file conversion

2 posts in this topic

My question is I'm sure backwards to many but I have existing text files which are all UTF-8 encoded. For backwards compatibility with another application that reads these files, I need to convert them all to ANSI. What is the best way to do this? other than a macro to file->open, file->save as, change to ansi, save, close. There must be an easier way to convert the entire file.

Thanks for any suggestions!

Share this post


Link to post
Share on other sites



Try parsing source files with these functions...

Func _UNICODE2ANSI($sString = "")
    ; Convert UTF8 to ANSI to insert into DB

    ; http://www.autoitscript.com/forum/index.php?showtopic=85496&view=findpost&p=614497
    ; ProgAndy
    ; Make ANSI-string representation out of UTF-8

    Local Const $SF_ANSI = 1
    Local Const $SF_UTF8 = 4
    Return BinaryToString(StringToBinary($sString, $SF_UTF8), $SF_ANSI)
EndFunc   ;==>_UNICODE2ANSI

Func _ANSI2UNICODE($sString = "")
    ; Extract ANSI and convert to UTF8 to display

    ; http://www.autoitscript.com/forum/index.php?showtopic=85496&view=findpost&p=614497
    ; ProgAndy
    ; convert ANSI-UTF8 representation to ANSI/Unicode

    Local Const $SF_ANSI = 1
    Local Const $SF_UTF8 = 4
    Return BinaryToString(StringToBinary($sString, $SF_ANSI), $SF_UTF8)
EndFunc   ;==>_ANSI2UNICODE

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