[windev] INI files and Russian

truckleaj-windev@yahoo.co.uk truckleaj-windev at yahoo.co.uk
Mon Apr 20 08:25:20 GMT 2009


This class ended up wgiving me what I needed:

http://www.codeproject.com/KB/files/textfiledocument.aspx

With a handful of lines of code I was able to read the ANSI INI into a buff=
er, by passing the right codepage property. Then I was able to replace the =
file with the unicode version. Then my application was happy to continue.

Seems to work fine. Good article.

Thanks for the input though (Serge too).

Andrew




________________________________
From: Chris Becke <Chris.Becke at derivco.com>
To: "windev at windev.org" <windev at windev.org>
Sent: Monday, 20 April, 2009 8:20:33
Subject: Re: [windev] INI files and Russian

On Windows the ANSI functions are supposed to mostly be wrappers around the=
 Unicode functions. That said I would have thought that GetPrivateProfileSt=
ringA() might have been clever enough to simply load the bytes up from an I=
NI file if the BOM (or lack thereof) implies the file contains multi byte d=
ata.

Although, now I think more about it that does seem less practical than simp=
ly 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 give=
n anything more complex than ascii data as the OS is going to try and round=
trip the data through unicode using that codepage.


-----Original Message-----
From: windev-bounces at windev.org [mailto:windev-bounces at windev.org] On Behal=
f 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 yo=
urs.

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=3D
> lstrlenA(szBuffer);intlenW;WCHAR*unicodestr;lenW=3D
> ::MultiByteToWideChar(1251, 0, szBuffer, lenA, 0, 0);if(lenW>
> 0)unicodestr=3D 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.=A0 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?=A0 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?=A0 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?=A0 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 wh=
ich 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 in=
tended =

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 opinio=
ns of the =

author, which are not necessarily the views and opinions of the company.
###########################################################################=
##################
-- =

Windev mailing list at Windev at windev.org

Lost your password?=A0 Need to unsubscribe or change your delivery options?=
=A0 =

Go to http://lists.windev.org/mailman/listinfo/windev
--
Search the Windev Archives - www.windev.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.windev.org/pipermail/windev/attachments/20090420/44c6a950=
/attachment.htm


More information about the Windev mailing list