Character set conversions

Jonathan M Davis jmdavisProg at gmx.com
Mon May 30 15:07:17 PDT 2011


On 2011-05-30 14:40, Jérôme M. Berger wrote:
> Daniel Gibson wrote:
> > In plain C (at least on Linux) you have fun locale-dependent in/output
> > as well: printf and scanf are locale dependent, so if you use sprintf
> > to generate a string you'll write into a file (or fprintf directly) with
> > one locale, reading it with scanf functions with another locale will
> > fail. Pretty fucking stupid IMHO.
> > This was/is(?) a bug in GtkRadiant, a level editor for Quake like games,
> > which uses printf or something to write the map files. The map compiler
> > will reject them if decimals use a , instead of a . and stuff like that.
> > (The workaround is to always use the standard LOCALE, i.e. "LC_ALL=C
> > gtkradiant" to start it).
> 
> 	Actually, that is the same issue: Excel outputs numbers to CSV in a
> locale dependent way (probably using printf), which means that in
> some locales the decimal point is a coma, which prevents using it as
> a field separator. Braindead of course, and a real pain when you
> want to interface with other software.

Well, knowing Microsoft, they probably did it with printf (or fprintf or 
whatever), not realizing that it had locale issues, but once they figured out, 
they wouldn't fix it because that would break backwards compatibility.

- Jonathan M Davis


More information about the Digitalmars-d mailing list