Home Bunny Posted April 28, 2009 Posted April 28, 2009 I'm reading files to convert the content to a SQL database. The thing i'm having is following: In my files (opened in SciTe) have sometimes a 'NUL' seperator: NUL; (the NUL is visible in white text, black background) with FileReadLine a empty string is returned, also it isn't posible to copy the 'NUL', gives also a empty string ... How can i proceed to read these lines?
Home Bunny Posted April 28, 2009 Author Posted April 28, 2009 (edited) Found it, the NUL character ==> StringToBinary( $chars ) = 0x00 for the ones that have the same problem: #include <Array.au3> Local $avArray[1] local $Line, $Line2 $i = 0 $file = FileOpen("Mydata.txt",0) ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in 1 character at a time until the EOF is reached While 1 $chars = FileRead($file, 1) If @error = -1 Then ExitLoop If StringToBinary( $chars ) <> 0x00 Then if $chars <> @LF Then $Line2 &= $chars Else If $Line2 <> "" Then _ArrayAdd($avArray, $Line2) EndIf $Line2 = "" EndIf EndIf Wend FileClose($file) _ArrayDisplay($avArray, $file) Regards Edited April 28, 2009 by Home Bunny
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