[Shapelib] Re: shapelib improvements

Mateusz Loskot mateusz at loskot.net
Thu Dec 6 07:09:41 PST 2007


Bram de Greve wrote:
> I guess I mixed up my text a little =)
> 
> It should read:
> 
> Still, I don't know what encoding to use ...  UTF-8 certainly doesn't
> work.  If I want to create file with as name the symbol pi (\u03C0),
> and I pass it as an UTF-8 encoded string (\xcf\x80), fopen will
> create a file with the name π (I hope that comes through, that's
> \xcf\u20ac).  Instead - If I read the documentation right - Windows
> will use an ANSI codepage depending on the user's regionale (CP_ACP).
> In my case, I guess that's ANSI 1252, and that can't represent the
> symbol pi (well, the encoding just converted it to the letter p).

fopen() function accepts encoding specific for local environment.
For example, on Polish version of Windows, it accepts Windows 1250
(latin2) on english - Windows 1252 (latin1) etc.
Every ASCII character is valid UTF-8, but not the other way.

This implies that fopen accepts only a subset of Unicode characters
included in particular code page but does not accept the whole range of
UTF-8.

Possible solution is to use Unicode-aware API availalbe on
Windows: _wfopen() (or CreateFile)
Some time ago I ported Shapelib to use wide-character versions of
I/O functions as I needed it on Windows CE (Unicode-only system).

Unfortunately, I have lost these modifications but it isn't a big
deal to do it.

Cheers
-- 
Mateusz Loskot
http://mateusz.loskot.net



More information about the Shapelib mailing list