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.
BOM and ReadString
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
BOM and ReadString
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.
Re: BOM and ReadString
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
Edit: okDebugger wrote: TestTest
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
Lizard - Script language for symbolic calculations and more ― Typeface - Sprite-based font include/module
-
- Always Here
- Posts: 6426
- Joined: Fri Oct 23, 2009 2:33 am
- Location: Wales, UK
- Contact:
Re: BOM and ReadString
...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
Edit: Related BOM issues:
http://www.purebasic.fr/english/viewtop ... 66#p433766
http://www.purebasic.fr/english/viewtop ... 13&t=55125
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
If it sounds simple, you have not grasped the complexity.