Re: Problems with file names containing latin accent characters

Jean-Claude Wippler <[email protected]> Mon, 12 Nov 2007 11:44:51 +0100
Newsgroups gmane.comp.db.metakit
Message-ID <[email protected]>
Riccardo Cohen wrote:

> I noticed also that on windows, metakit needs utf8 file names. But did
> not test on other platforms.I supposed all platforms need utf8 ?

Yes.

> Anyway I rather changed my code to give utf8 to metakit. Any precision
> would be appreciated.

That's correct.  For maximum portability, all strings in and out of =20
Metakit should be in UTF8.

> Tecnonucleo wrote:
>
>> I've used Metakit for a while, and recently I had some issues with
>> file names containing accent characters, like =E1 or =E9. It only occurs
>> in Windows XP. In Linux all works ok.
>> But in Windows, when the file name had latin accent characters,
>> Metakit suppress them and thus it tried to open a non existing file.
>> I debug into Metakit source code and I found that the character
>> missing happened in this line:
>>
>> MultiByteToWideChar(CP_UTF8, 0, fname_,  - 1, wName, MAX_PATH);
>>
>> I'm not an expert in Win32 API, but after some googling I decided to
>> change the CP_UTF8 parameter for CP_ACP. And then all began to work =20
>> ok
>> as in Linux. The new version of the previous line now looks like =20
>> that:
>>
>> MultiByteToWideChar(CP_ACP, 0, fname_,  - 1, wName, MAX_PATH);
>>
>> I'm not sure if it make sense to change the Metakit sources that way,
>> but in any case I want to share this issue and maybe get some =20
>> feedback
>> about the patch I applied.

What you've done is change the calling convention so Metakit expects a =20
Windows-specific "codepage" encoding.

(Google tells me that CP_ACP means "I do not care what the system =20
default codepage is -- just use it")

While this works, you lose some flexibility: what if you wanted to =20
save to a filename which has characters outside the range used in your =20
own locale?  With UTF8 everywhere, you can use filenames with any =20
characters in them on any system.  The consequence though, is that you =20
have to do what Riccardo did: convert filenames to UTF8 before passing =20
them to Metakit.

-jcw


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "metakit" group.=

To post to this group, send email to [email protected]
To unsubscribe from this group, send email to metakit-unsubscribe@googlegrou=
ps.com
For more options, visit this group at http://groups.google.com/group/metakit=
?hl=3Den
-~----------~----~----~----~------~----~------~--~---