[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Sat, 28 Apr 2001 09:29:08 +0100
While I have just committed a hack to use NSDecimalSeparator in strings,
I suspect that
what I've done is wrong.
Currently, GNUstep sets the current locale in the libc code to the
locale specified by
the environment variables using setlocale(). This makes libc functions
produce output according to the values specified in the environment.
Since the stringWithFormat: routines use sprintf for formatting floating
this means that everything gets formatted the way the environment
My hack attempts to rewrite the output of sprintf to conform to the
specified in the locale dictionary.
Having run some tests on MacOS-X, I think this is wrong.
It looks to me as if the 'C' or 'POSIX' locale should always be used
except for methods
(use [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]
(use supplied locale dictionary for formattting)
So, I think that GNUstep should behave as follows -
On startup, setlocale() to the environment variable supplied values, and
locale to provide default values for the OpenStep locale dictionary.
Then use setlocale() again to set the locale to the POSIX locale - so
that this will
be used as default.
Thereafter, all non localised formatting, and in particular, all
by standard libc functions, will be according to the POSIX locale.
GSSetLocale() function should be removed, so use of the POSIX locale is
Localised methods where no dictionary is supplied, will use the values
Localised methods with a dictionary supplied will use the formatting
in the dictionary.
Ideally, the code in GSFormat.m should be extended to handle floats
rather than using sprintf() ... I think any rewriting of sprintf()
going to be error prone and inefficient.
- Locale usage,
Richard Frith-Macdonald <=