Jump to content

UTF-8 to ANSI text file conversion


Recommended Posts

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!

Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...