freebasic / fbc

FreeBASIC is a completely free, open-source, multi-platform BASIC compiler, with syntax similar to MS-QuickBASIC, that adds new features such as pointers, object orientation, unsigned data types, inline assembly, and many others.
https://www.freebasic.net
877 stars 137 forks source link

File Append Bug #393

Closed nsiatras closed 2 years ago

nsiatras commented 2 years ago

I noticed that Append to file using encoding doesn't work. I also discussed this on FreeBasic discord and I verified this issue with others.

This doesn't works:

Dim filePath as String = "C:\Users\nsiat\Desktop\Test.txt"
Open filePath For Append encoding "UTF8" As #1
print #1,"TEST"
Close #1

This works:

Dim filePath as String = "C:\Users\nsiat\Desktop\Test.txt"
Open filePath For Append  As #1
print #1,"TEST"
Close #1
jayrm commented 2 years ago

@nsiatras, thank-you for the report.

opening a non-existent file for append always failed because of an incorrect check for not yet written BOM opening an existing file for append always failed because the file mode didn't support reading the existing BOM

When opening an encoded file (e.g. utf-8) for append:

394 should fix this bug.