delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/03/10:43:52

Date: Sun, 3 May 1998 17:42:05 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "John M. Aldrich" <fighteer AT cs DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: OTP: European decimal notation (Was Re: Problems with paranoia.c and pow(0,0))
In-Reply-To: <3547B0B9.2B05@cs.com>
Message-ID: <Pine.SUN.3.91.980503174143.19706L-100000@is>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019