IDE - Save source code(*.pb?) with BOM if UTF-8 checked.

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

IDE - Save source code(*.pb?) with BOM if UTF-8 checked.

Post by skywalk »

Fred solved a weird Unicode string bug I had.
This snippet works fine in a standalone UTF-8 source file compiled with Unicode.
But within a larger app(many IncludeFiles) the 1st char of each word was dropped. Fred told me to check all my source files had the UTF-8 BOM and some did not.

Code: Select all

Define$ s$ = "ŠTEPÁNEK ŽIGIC lives."
Debug s$    ; Without UTF-8 BOM, prints " TEPÁNEK  IGIC lives."
It would have spared me debug time if the IDE saved my source files(.pb? only) as UTF-8 + BOM when my preferences select UTF-8 sources.
Also, I would not have to open them in an external editor like NotePad++ just to "Convert to UTF-8".
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: IDE - Save source code(*.pb?) with BOM if UTF-8 checked.

Post by Little John »

skywalk wrote:It would have spared me debug time if the IDE saved my source files(.pb? only) as UTF-8 + BOM when my preferences select UTF-8 sources.
Are you saying that on your system the PB IDE (always/sometimes?) saves UTF-8 source files without BOM?
If my memory serves me right, my UTF-8 source files always have been saved by the IDE with BOM.
User avatar
skywalk
Addict
Addict
Posts: 4211
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: IDE - Save source code(*.pb?) with BOM if UTF-8 checked.

Post by skywalk »

Yes, that makes sense the IDE would store the BOM but it was definitely not the case for many of my pb includes. I don't know the IDE's save logic since the appended IDE options do not have a switch for UTF-8? Maybe they were originally created with Plain text? However, once the user selects UTF-8, I think the IDE should save the BOM.

Code: Select all

; IDE Options = PureBasic 5.31 (Windows - x86)
; CursorPosition = 527
; FirstLine = 494
; Folding = ---
; EnableUnicode
; UseIcon = img\my.ico
; Executable = my.exe
; CurrentDirectory = C:\myprj\
; CompileSourceDirectory
; IncludeVersionInfo
; VersionField0 = %yy,%mm,%dd,0
; VersionField1 = %yy,%mm,%dd,0
; VersionField2 = myco
; VersionField3 = myapp
; VersionField4 = %yy.%mm.%dd
; VersionField5 = %yy.%mm.%dd
; VersionField6 = myapp
; VersionField7 = myapp
; VersionField8 = myapp.exe
; VersionField13 = me@myco.com
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
User avatar
Shield
Addict
Addict
Posts: 1021
Joined: Fri Jan 21, 2011 8:25 am
Location: 'stralia!
Contact:

Re: IDE - Save source code(*.pb?) with BOM if UTF-8 checked.

Post by Shield »

Just as a side note here, a BOM should not be used for UTF-8 files according to the standard specs. :)
Unicode Specs wrote: Use of a BOM is neither required nor recommended for UTF-8
Image
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Post Reply