Jump to content
Sign in to follow this  
orbs

does FileReadToArray() detect file encoding automatically?

Recommended Posts

orbs

the help file states: "... functions such as FileReadLine..." regarding functions that automatically detect the file encoding. which are the other "such" functions? is FileReadToArray() one of them?

i'm also unsure on how to test this. i used a simple script to FileOpen() a new text file with all encoding formats mentioned in the FileOpen() help. then i used FileReadToArray() to read it - i get back a good result for all encoding formats. so either FileReadToArray() is detecting the encoding properly, or i'm testing it wrong. how can i be sure?

EDIT: that's my test script. using 128,64,32,16 instead of 256 for encoding formats.

#include <Array.au3>

$sFile=@ScriptDir&'\FileReadToArray-test.txt'

$hFile=FileOpen($sFile,2+256)
FileWriteLine($hfile,'Line1')
FileWriteLine($hfile,'Line2')
FileClose($hFile)

$a=FileReadToArray($sFile)
_ArrayDisplay($a)
Edited by orbs

Share this post


Link to post
Share on other sites
czardas

I would say your testing method is sound. Rather than just opening the files, I assume you also wrote to each file with different encoding options. I can't imagine how FileReadToArray could work at all if it didn't automatically detect the encoding.

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  

×