Page 1 of 1

BOM and ReadString

Posted: Thu Jul 18, 2013 1:45 am
by IdeasVacuum
File with a BOM prefix (Byte Order Mark)

If ReadString() is used to read a file line-by-line, all is well.

If however ReadString() is used to read the whole file, flagged #PB_File_IgnoreEOL, the BOM is included in the String, which is a pity.

Edit: The solution is to use ReadStringFormat() first, which will move the file pointer behind the BOM if one is detected.

Re: BOM and ReadString

Posted: Thu Jul 18, 2013 2:04 am
by STARGĂ…TE
No problem here:

Code: Select all

If ReadFile(1, "Test.txt")
	ReadStringFormat(1)
	Debug ReadString(1, #PB_File_IgnoreEOL)
	CloseFile(1)
EndIf
Test.txt wrote: %EF%BB%BFTest%0D%0ATest
Debugger wrote: TestTest
Edit: ok

Re: BOM and ReadString

Posted: Thu Jul 18, 2013 11:59 am
by IdeasVacuum
...it's not that it's a problem, just that #PB_File_IgnoreEOL is inconsistent, given that without that flag, the BOM is ignored.

Edit: Related BOM issues:
http://www.purebasic.fr/english/viewtop ... 66#p433766
http://www.purebasic.fr/english/viewtop ... 13&t=55125