Re: Using GetPrivateProfileString to read unicode strings
- From: Scot T Brennecke <ScotB@xxxxxxxxxxxxxxxxxx>
- Date: Sun, 23 Aug 2009 14:24:42 -0500
Fair enough. If the API were created anytime within the last decade or so, I'm sure it would have been done more smartly. For portable settings files, XML format is a much more useful choice.
Joseph M. Newcomer wrote:
What is not obvious from this is that you must create the file yourself, external to the.
WritePrivateProfileString. For example, I had assumed if I called
WritePrivateProfileStringW, I would get a Unicode version of the file, but the article
makes it clear that this really only deals with the input arguments, not the file format.
The fact that the file *cannot* be created as Unicode solely by the APIs is not at all
obvious from those statements.
joe
On Sat, 22 Aug 2009 22:41:11 -0500, Scot T Brennecke <ScotB@xxxxxxxxxxxxxxxxxx> wrote:
Both of these articles state "If the file exists and was created using Unicode characters, the function writes Unicode characters to the file. Otherwise, the function creates a file using ANSI characters."Joseph M. Newcomer [MVP]
WritePrivateProfileString Function (Windows):
http://msdn.microsoft.com/en-us/library/ms725501.aspx
WritePrivateProfileSection Function (Windows):
http://msdn.microsoft.com/en-us/library/ms725500.aspx
Joseph M. Newcomer wrote:The error appears to be that it is not documented that it does this. I have no problem
with the design, but it needs to say that. According to the cited article, this fact is
not documented.
Note that I primarily am reporting errors of documentation. Sometimes I point out that
the design is flawed. But mostly, it is the omission of crtical information that should
have been written down.
The issue of "carrying settings around" sometimes suggests .INI files, so more people use
them than Microsoft intended. So the reality is that this behavior needs to be
documented, and the failure to provide clear documentation of this interesting behavior is
the "error" I want to cite.
joe
On Sat, 22 Aug 2009 15:50:37 -0500, Scot T Brennecke <ScotB@xxxxxxxxxxxxxxxxxx> wrote:
Come on, Joe. It's not an error. It's by design, and documented. Furthermore, it states this: "Note This function is provided only for compatibility with 16-bit versions of Windows. Applications should store initialization information in the registry." back in 16-bit days, we didn't even have Unicode.Joseph M. Newcomer [MVP]
Joseph M. Newcomer wrote:Fascinating! Could I incorporate parts of that article into my MSDN Errors document, with
a hyperlink to your document?
joe
On Sat, 22 Aug 2009 01:04:10 -0700, "Mihai N." <nmihai_year_2000@xxxxxxxxx> wrote:
Joseph M. Newcomer [MVP]Can i use GetPrivateProfileString/WritePrivateProfileString to read/Trick: if the file does not exist, or exists but it is not Unicode, then
write unicode strings from a file ?
the functions will convert everything to ANSI.
If you want to be unicode, then create an empty file with a BOM only
(FE FF) and then everything you write will be Unicode.
http://blogs.msdn.com/michkap/archive/2006/09/15/754992.aspx
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
- References:
- Using GetPrivateProfileString to read unicode strings
- From: singurd
- Re: Using GetPrivateProfileString to read unicode strings
- From: Mihai N.
- Re: Using GetPrivateProfileString to read unicode strings
- From: Joseph M . Newcomer
- Re: Using GetPrivateProfileString to read unicode strings
- From: Scot T Brennecke
- Re: Using GetPrivateProfileString to read unicode strings
- From: Joseph M . Newcomer
- Re: Using GetPrivateProfileString to read unicode strings
- From: Scot T Brennecke
- Re: Using GetPrivateProfileString to read unicode strings
- From: Joseph M . Newcomer
- Using GetPrivateProfileString to read unicode strings
- Prev by Date: Re: Manifest problem in VS2008
- Next by Date: Re: Manifest problem in VS2008
- Previous by thread: Re: Using GetPrivateProfileString to read unicode strings
- Next by thread: Re: Using GetPrivateProfileString to read unicode strings
- Index(es):
Relevant Pages
|