avechuche Posted June 15, 2015 Share Posted June 15, 2015 Hello. I have a ".txt" file that X number of lines at the end of each line has a character that if opened with Windows Notepad, seems a blank, but if you open it with Notepad ++, a character "NULL" . The problem is that when I make a FileRead, just read me until the first NULL. Is there any way to fix it? Thanks! Link to comment Share on other sites More sharing options...
232showtime Posted June 16, 2015 Share Posted June 16, 2015 let me give you a piece of advice, post your code so expert coders can analyze your script. ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon. Link to comment Share on other sites More sharing options...
avechuche Posted June 16, 2015 Author Share Posted June 16, 2015 (edited) This code $sFile = FileRead("Example.txt")Return only first line :SBut if I use a loop + FileReadLine, it works perfectly, but I need to process data faster that read line by line.Example.txt Edited June 16, 2015 by avechuche Link to comment Share on other sites More sharing options...
AspirinJunkie Posted June 16, 2015 Share Posted June 16, 2015 The file contains Null-Chars (a char with the value 0). A text file is ending at this char. So if you handle the file as a text file, the file only gets read until the first Null.But because the file contains text information anyway i would say the file ist corrupt - because a Null-character has no place inside a text file.The solution: Handle the file as a binary file and kill the Null-chars:$hFile = FileOpen("Example.txt", 16) $sFile = StringReplace(BinaryToString(FileRead($hFile)), Chr(0), "", 0, 1) FileClose($hFile) ConsoleWrite($sFile) avechuche 1 Link to comment Share on other sites More sharing options...
avechuche Posted June 16, 2015 Author Share Posted June 16, 2015 The file contains Null-Chars (a char with the value 0). A text file is ending at this char. So if you handle the file as a text file, the file only gets read until the first Null.But because the file contains text information anyway i would say the file ist corrupt - because a Null-character has no place inside a text file.The solution: Handle the file as a binary file and kill the Null-chars:$hFile = FileOpen("Example.txt", 16) $sFile = StringReplace(BinaryToString(FileRead($hFile)), Chr(0), "", 0, 1) FileClose($hFile) ConsoleWrite($sFile) Perfect!!! THX! Link to comment Share on other sites More sharing options...
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