locale fixes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28756 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2009-09-30 20:44:41 +00:00
parent 8e2d2ce1e1
commit 49dd10cc29
2 changed files with 12 additions and 9 deletions

View file

@ -3,6 +3,7 @@
* Source/NSLock.m: Fix BOOL methods to return YES or NO.
* Source/win32/GSFileHandle.m: Implement nul device handle.
* Source/NSTask.m: Try to avoid annoying colsole window with mingw32
* Source/GSLocale.m: Try to handle locale setup in non-utf8 locales.
2009-09-27 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -51,6 +51,9 @@ GSSetLocaleC(int category, const char *loc)
return setlocale(category, loc);
}
#define ToString(value) [NSString stringWithCString: (value) \
encoding: GSPrivateNativeCStringEncoding()]
/* Set the locale for libc functions from the supplied string or from
the environment if not specified. This function should be called
as soon as possible after the start of the program. Passing
@ -78,13 +81,12 @@ GSSetLocale(int category, NSString *locale)
locale = nil;
if (clocale != 0)
{
locale = [NSString stringWithUTF8String: clocale];
locale = ToString(clocale);
}
return locale;
}
#define GSLanginfo(value) [NSString stringWithCString: nl_langinfo (value) \
encoding: GSPrivateNativeCStringEncoding()]
#define GSLanginfo(value) ToString(nl_langinfo (value))
/* Creates a locale dictionary from information provided by i18n functions.
@ -164,33 +166,33 @@ GSDomainFromDefaultLocale(void)
/* Currency Information */
if (lconv->currency_symbol)
{
[dict setObject: [NSString stringWithUTF8String: lconv->currency_symbol]
[dict setObject: ToString(lconv->currency_symbol)
forKey: NSCurrencySymbol];
}
if (lconv->int_curr_symbol)
{
[dict setObject: [NSString stringWithUTF8String: lconv->int_curr_symbol]
[dict setObject: ToString(lconv->int_curr_symbol)
forKey: NSInternationalCurrencyString];
}
if (lconv->mon_decimal_point)
{
[dict setObject: [NSString stringWithUTF8String: lconv->mon_decimal_point]
[dict setObject: ToString(lconv->mon_decimal_point)
forKey: NSInternationalCurrencyString];
}
if (lconv->mon_thousands_sep)
{
[dict setObject: [NSString stringWithUTF8String: lconv->mon_thousands_sep]
[dict setObject: ToString(lconv->mon_thousands_sep)
forKey: NSInternationalCurrencyString];
}
if (lconv->decimal_point)
{
[dict setObject: [NSString stringWithUTF8String: lconv->decimal_point]
[dict setObject: ToString(lconv->decimal_point)
forKey: NSDecimalSeparator];
}
if (lconv->thousands_sep)
{
[dict setObject: [NSString stringWithUTF8String: lconv->thousands_sep]
[dict setObject: ToString(lconv->thousands_sep)
forKey: NSThousandsSeparator];
}