Page 1 of 1
CreatePreferences()
Posted: Fri May 15, 2015 9:45 pm
by NoahPhense
Not sure what version this started at.. because I have not been coding for while. But the code below I have in a lot of my apps. Been testing it and now, it creates a
blank line 1 in a new file. (?)
Code: Select all
Procedure.b WriteINIFile_New()
ret.b = 0
If CreatePreferences("my.ini")
PreferenceComment("")
PreferenceComment("xxx")
PreferenceComment("")
PreferenceGroup("settings")
WritePreferenceString("xxx", "xxx")
ClosePreferences()
ret + 1
EndIf
ProcedureReturn ret
EndProcedure
- np
Re: CreatePreferences()
Posted: Sat May 16, 2015 1:21 am
by kenmo
I have seen this too (PB 5.31 / Windows).
It only happens in Unicode mode!
It's also one of the things I mention (and "fix") in this post yesterday
http://www.purebasic.fr/english/viewtop ... 12&t=62236
Re: CreatePreferences()
Posted: Sat May 16, 2015 2:48 am
by NoahPhense
Hey Kenmo, that's some great code you made there. Looks like you put a lot of thought into it. I will give it a check later.
For now, I have changed out of Unicode. That fixed the empty first line.
- np
Re: CreatePreferences()
Posted: Wed Aug 05, 2015 8:20 am
by Fred
Re: CreatePreferences()
Posted: Wed Aug 05, 2015 3:42 pm
by kenmo
Thanks for the link, Fred. The reason makes sense now -- the newline is added as a divider between the UTF-8 BOM and the first key name.
So instead, how about a #PB_Preference_NoBOM flag (which would remove the BOM and the newline) for those of us who prefer the
UTF-8 Everywhere approach
utf8everywhere.org wrote:From the Unicode Standard (v6.2, p.30): "Use of a BOM is neither required nor recommended for UTF-8".
Byte order issues are yet another reason to avoid UTF-16. UTF-8 has no endianness issues, and the UTF-8 BOM exists only to manifest that this is a UTF-8 stream. If UTF-8 remains the only popular encoding (as it already is in the internet world), the BOM becomes redundant. In practice, most UTF-8 text files omit BOMs today.