Jump to content

Reading UTF-8 Files


Ejoc
 Share

Recommended Posts

So I've been searching and searching, but haven't found any examples that cover what I'm trying to do, which as far as I can tell should be simple.

How do I read a UTF-8 encoded text file and have the unicode characters preserved in the script? As it is now, the unicode characters are "mangled" and the 3 character header at the beginning of the file is being read in as ascii.

Ideally I would be able to use FileOpen() and FileReadLine()

I just need it displayed correctly in the GUI

Thanks

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs
Link to comment
Share on other sites

Try using FileOpen with UTF-8 mode.

- The Kandie Man ;-)

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

The help file for Filopen makes no mention of this

What version of AutoIt are you using? Older versions of AutoIt didn't have this option. This option has been around for probably about a year though now.

http://www.autoitscript.com/autoit3/docs/f...ns/FileOpen.htm

- The Kandie Man ;-)

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Link to comment
Share on other sites

  • Moderators

The help file for Filopen makes no mention of this

You must have an old version of AutoIt :)

FileOpen

--------------------------------------------------------------------------------

Opens a text file for reading or writing.

FileOpen ( "filename", mode )

Parameters

filename Filename of the text file to open.

mode Mode (read or write) to open the file in.

Can be a combination of the following:

0 = Read mode

1 = Write mode (append to end of file)

2 = Write mode (erase previous contents)

4 = Read raw mode

8 = Create directory structure if it doesn't exist (See Remarks).

16 = Force binary(byte) reading and writing mode with FileRead and FileWrite

32 = Use Unicode UTF16 Little Endian mode when writing text with FileWrite and FileWriteLine (default is ANSI)

64 = Use Unicode UTF16 Big Endian mode when writing text with FileWrite and FileWriteLine (default is ANSI)

128 = Use Unicode UTF8 when writing text with FileWrite and FileWriteLine (default is ANSI)

Both write modes will create the file if it does not already exist. The folder path must already exist (except using mode '8' - See Remarks).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...