Seminko Posted January 25, 2020 Posted January 25, 2020 (edited) I have a TSV file that I want to read but can't seem to. It opens without an error but fails on FIleRead giving me error 1 which, as per the documentation, happens when file is not opened in read mode (not my case, I use the 0 parameter with FileOpen) OR other error, which is pretty vague. $sFilePath = "G:\Čest\test.tsv" Local $hFileOpen = FileOpen($sFilePath, 0) If @error Then MsgBox(1, "error fileopen", @error) ; getting no errors when opening the file EndIf $test = FileRead($hFileOpen) If @error Then MsgBox(1, "error FileRead", @error) ; here's where I get the error EndIf FileClose($hFileOpen) I googled and found a similar case where there we null characters in the binary. The example given to identify those chars was this one: Local $h_open = FileOpen("G:\Čest\test.tsv", 16) Local $s_binary = FileRead($h_open) FileClose($h_open) Local $i For $i = 1 To BinaryLen($s_binary) If Execute(BinaryMid($s_binary, $i, 1)) = 0 Then MsgBox(16, "Oops", "Character: " & $i & " is a NULL char.") EndIf Next However, no MsgBox with null chars... Any ideas why I can't read the file? EDIT: I can't seem to read any file, even txt. Edited January 25, 2020 by Seminko
Seminko Posted January 25, 2020 Author Posted January 25, 2020 Found the issue. Leaving it here since it might be useful for others. The actual filePath had a czech character - 'Č', so let's say 'G:\Čest\test.tsv' I had my encoding set to Code Page Property instead of UTF-8. For some reason fileopen didn't throw an error but fileread did. Might that be a bug? Obviously after changing the encoding to UTF-8 the problem went away.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now