Jump to content

How to force FileRead read UTF-16? (Solved)


Recommended Posts

Hi!

This windows/console command:

CMD /U /C DIR *.jpg > listdir.txt
give a file, in UTF-16. But this file has no "Unicode-UTF16 header".

FileRead don't open the file with UTF-16 decoding.

Any idea, for force FileRead to use UTF-16?

Thanks in advance.

Edited by Michel Claveau
Link to comment
Share on other sites

Take a look at the mode parameters for FileOpen() in the help file. You can force the file to open in UTF-16 before you read it.

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

Hi!

Thank you, but (Aaaarrrrggghh!!!) this parameter is only for Writing, and don't run for reading.

Sorry, I must've overlooked that. However, from the help file entry for FileRead():

Both ANSI and UTF16/UTF8 text formats can be read - AutoIt will automatically determine the type.

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Link to comment
Share on other sites

re-Hi!

AutoIt will automatically determine the type.

OK, but for that, AutoIt use the "Unicode-header" (FF-FE or FE-FF, for UTF-16). Unfortunately, sometimes, this information is missing, as in the case that I gave.

That is why I try to "force" the mode of reading in Autoit.

Link to comment
Share on other sites

how about FileOpen, view as hex, add the header, save and now open?

I know it might sound stupid and I'm not even sure if it will work but that's the only way I could think about.

Link to comment
Share on other sites

Hi!

how about FileOpen, view as hex, add the header, save and now open?

I know it might sound stupid and I'm not even sure if it will work but that's the only way I could think about.

I reached the same conclusion.

Too bad we can not force the encoding FileRead :-(

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