NUL character in a text file read by NAV

andy76andy76 Member Posts: 616
Hello,

we have problems with an enormous text file supplied us by ftp and containing a lot of price lists.

From yesterday we have problems and I try to debug and analyze.
Inside the text file (opened with Notepad ++) I have a lot of NUL value that I don't see with standard Notepad of Windows.

Debugging I see that the lines read are broken where there is the NUL value.

I ask you how to solve it with CSIDE code.

Actual code is


WHILE NOT gIstlFileToRead.EOS DO BEGIN
gIstlFileToRead.READTEXT(gTxtLineRead,1024);

gIstlFileToRead is a File variable
gTxtLineRead is a Text [1024]

Thank you

and then

Comments

  • vaprogvaprog Member Posts: 1,141
    First of all I recommend you contact the originator of the file and ask for a corrected file. A file containing NUL characters is generally considered to be a binary file, not a text file (unless almost every second char is NUL, in which case it is likely in UTF-16 encoding).

    Other options you have:
    • fix the file yourself before you read it with NAV
    • read the file as it is and try to detect breaks caused by NUL characters and join strings as needed
    • read the file as binary, fix the NUL characters (as you should not place these in NAV fields), then split into lines in code and proceed
    andy76 wrote:
    gIstlFileToRead is a File variable
    No, it's an InStream. You might want to check File.READ with TEXTMODE TRUE or FALSE also.
Sign In or Register to comment.