[windev] INI files and Russian
Chris Becke
Chris.Becke at derivco.com
Mon Apr 20 07:20:33 GMT 2009
On Windows the ANSI functions are supposed to mostly be wrappers around the Unicode functions. That said I would have thought that GetPrivateProfileStringA() might have been clever enough to simply load the bytes up from an INI file if the BOM (or lack thereof) implies the file contains multi byte data.
Although, now I think more about it that does seem less practical than simply having a unicode core that can read all formats of file.
Anyway, the lesson is, the "Language for non-Unicode Programs" setting MUST imply the correct codepage or the ANSI functions are going to fail if given anything more complex than ascii data as the OS is going to try and roundtrip the data through unicode using that codepage.
-----Original Message-----
From: windev-bounces at windev.org [mailto:windev-bounces at windev.org] On Behalf Of Serge Wautier
Sent: Monday, April 20, 2009 7:55 AM
To: truckleaj-windev at yahoo.co.uk; windev at windev.org
Subject: Re: [windev] INI files and Russian
GetPrivateProfileStringA() uses the system code page to read the contents.
Which means it would work on Russian computers even though it doesn't on yours.
HTH,
Serge.
http://www.apptranslator.com
> -----Original Message-----
> From: windev-bounces at windev.org [mailto:windev-bounces at windev.org] On
> Behalf Of truckleaj-windev at yahoo.co.uk
> Sent: dimanche 19 avril 2009 20:48
> To: truckleaj-windev at yahoo.co.uk; windev at windev.org
> Subject: Re: [windev] INI files and Russian
>
> I am not getting very far with this:
> {charszBuffer[_MAX_PATH];GetPrivateProfileStringA("labels",
> "lblhighlights", "", szBuffer, _MAX_PATH, "c:\\test.ini");intlenA=
> lstrlenA(szBuffer);intlenW;WCHAR*unicodestr;lenW=
> ::MultiByteToWideChar(1251, 0, szBuffer, lenA, 0, 0);if(lenW>
> 0)unicodestr= newWCHAR[lenW];// Check whether conversion was
> successful::
> }MultiByteToWideChar(CP_ACP, 0, szBuffer, lenA, unicodestr,
> lenW);else{// handle the error}
>
> I don't understand it.
>
> Why can't I take a INI file that I know is ANSI and contains Russian
> script and extract data from it into a CString in a unicode app?
>
> At the moment the only way I get things working is by running my app
> inside MS AppLocale with Russian codepage. I have tried using 1251 as
> the codepage and ity makes no difference.
>
> I have googled for two days now and not come up with solution.
>
> Andrew
>
>
>
>
> ________________________________
> From: "truckleaj-windev at yahoo.co.uk" <truckleaj-windev at yahoo.co.uk>
> To: windev at windev.org
> Sent: Friday, 17 April, 2009 22:28:31
> Subject: [windev] INI files and Russian
>
> Hello
>
> I try keep this brief and to the point.
>
> My application is Unicode and is running in Russian.
>
> It executes a 3rd party application which is not unicode and waits for
> it to create a INI file.
>
> This INI file is not unicode, but contains russian content.
>
> The only way I can view the russian content as cryllic is by running
> notepad inside ms applocale (set to russian) and then opening the INI
> file.
>
> My problem is that my program is unicode. When I do
> GetPrivateProfileString with this ANSI text file, it is not providing
> me Russian cryllic content.
>
> If I take the file that was opened in notepad (via ms applocale) and
> save as unicode, and use that in my program, I get good cryllic output.
>
> I can't change how the INI file is created as it is done by the 3rd
> party app. So is there a way that I can still use
> GetprivateProfileString with this ansi file inside my unicode app and
> end up with the unicode russian text?
>
> I hope I am making sense.
>
> Andrew
> -------------- next part -------------- An HTML attachment was
> scrubbed...
> URL:
> http://lists.windev.org/pipermail/windev/attachments/20090417/1c5e06e5
> /
> attachment.htm
> --
> Windev mailing list at Windev at windev.org
>
> Lost your password? Need to unsubscribe or change your delivery
> options?
> Go to http://lists.windev.org/mailman/listinfo/windev
> --
> Search the Windev Archives - www.windev.org delete[] unicodestr;
> -------------- next part -------------- An HTML attachment was
> scrubbed...
> URL:
> http://lists.windev.org/pipermail/windev/attachments/20090419/749aa5ea
> /
> attachment.htm
> --
> Windev mailing list at Windev at windev.org
>
> Lost your password? Need to unsubscribe or change your delivery
> options?
> Go to http://lists.windev.org/mailman/listinfo/windev
> --
> Search the Windev Archives - www.windev.org
--
Windev mailing list at Windev at windev.org
Lost your password? Need to unsubscribe or change your delivery options?
Go to http://lists.windev.org/mailman/listinfo/windev
--
Search the Windev Archives - www.windev.org
#############################################################################################
The information transmitted is intended only for the person or entity to which it
is addressed and may contain confidential and/or privileged material.
Any review, retransmission, dissemination or other use of, or taking of any action
in reliance upon, this information by persons or entities other than the intended
recipient is prohibited. If you received this in error, please contact the sender and
delete the material from any computer.
Furthermore, the information contained in this message, and any attachments thereto, is
for information purposes only and may contain the personal views and opinions of the
author, which are not necessarily the views and opinions of the company.
#############################################################################################
More information about the Windev
mailing list