Mail Archives: djgpp/1998/05/03/10:43:52
On Wed, 29 Apr 1998, John M. Aldrich wrote:
> So, is there a special language variant of C/C++ for Europeans where the
> role of ',' and '.' are reversed, and special European calculators and
> numeric keypads? Or do you just have to remember to type numbers in the
> American style when you program? It could be extremely confusing either
> way.
This pertains to locales. ANSI C has a provision for `setlocale' and
`localeconv' functions (which see) to solve this. (Sadly, DJGPP
currently doesn't implement anything beyond the minimum.) The
drawback of this is that you can only have a single locale active at
any given time, so if you need to do I/O in two or more different
notations, you are in for some hard work.
C++ has a facility called ``facets'' which is a generalization of
locales.
Of course, it all calls for programmer's vigilance to write code that
sets a correct locale and complies with the current locale, which
might explain why so many programs don't.
FWIW, GNU Emacs looks up the environment for locale-related variables
at startup, and changes its behavior accordingly (not as far as the
comma goes, though), so it's not impossible.
- Raw text -