discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Localization of libc and number handling


From: Alexander Malmberg
Subject: Re: Localization of libc and number handling
Date: Mon, 23 Jun 2003 18:00:30 +0200

Andreas Heppel wrote:
[snip]
> > I'm not sure you should rely on being able to parse what -description
> > returns, but I think its behavior is correct. From what I've seen, all
> > methods that deal with locale and don't have an explicit locale argument
> > use the nil/default/c locale, so I'd expect -description to do this as
> > well.
> >
> The thing is, not I am relying on -description, but -floatValue of NSCell does
> (more or less, that is). Tracing this call down into the depths of GNUstep
> ends up with -description, which, as you already expect, uses nil as locale.
> Unfortunately, it is not me (or in this case Enrico), who is mixing up libc
> and GNUstep, but it's GNUstep itself, as the method -floatValue, for instance,
> of an NSString uses atof() on the value returned by -lossyCString. And
> -description comes into play, for instance, in NSCell's -setObjectValue. It
> could be avoided (if I understand the code properly) by employing a formatter
> for the cell.

Seems like that would only be a workaround, though.

> I haven't tried this, yet.
> No, I just checked NSNumberFormatter. It simply returns, guess what,
> -description for the object.
> I looks a bit incomplete.
> Nevertheless, IMHO, an NSNumber should take into account the user's locale
> when building it's description. At least it should take into account the
> (first) value in NSLanguages, in the hope that this is coherent with the LANG
> setting.

No, it shouldn't. If you want localized number formatting, you need to
explicitly request localized formatting (eg. using [NSNumberFormatter
-setLocalizesFormat:], or [NSString +localizedStringWithFormat:];
there's also -descriptionWithLocale:, but it's only available in some
classes).

[snip]
> How does OpenStep locale handling work?

Locale information is stored in dictionaries, and there are formatting
methods that take these locale dictionaries as arguments. Normally,
you'd pass in nil to get a default locale (kindof like the c or posix
libc locale, I guess), or [[NSUserDefaults +standardUserDefaults]
dictionaryRepresentation] to get locale the user has set.

> I am not surprised at all about this error report, as in the depths og GNUstep
> libc functions are used (which are localized).

- Alexander Malmberg




reply via email to

[Prev in Thread] Current Thread [Next in Thread]