зеркало из https://github.com/mozilla/gecko-dev.git
bug 257511 : In UTF-8 locales, date/time with non-ASCII characters become 'null' strings (r=smontagu, sr=neil) (add back '##PLATFORM' to the Unix locale code)
This commit is contained in:
Родитель
319afa2a8f
Коммит
527fba9f3c
|
@ -201,9 +201,9 @@ nsLocaleService::nsLocaleService(void)
|
|||
#if (defined(XP_UNIX) && !defined(XP_MACOSX)) || defined(XP_BEOS)
|
||||
nsCOMPtr<nsIPosixLocale> posixConverter = do_GetService(NS_POSIXLOCALE_CONTRACTID);
|
||||
|
||||
nsAutoString xpLocale;
|
||||
nsAutoString xpLocale, platformLocale;
|
||||
if (posixConverter) {
|
||||
nsAutoString category;
|
||||
nsAutoString category, category_platform;
|
||||
nsLocale* resultLocale;
|
||||
int i;
|
||||
|
||||
|
@ -214,20 +214,28 @@ nsLocaleService::nsLocaleService(void)
|
|||
for( i = 0; i < LocaleListLength; i++ ) {
|
||||
nsresult result;
|
||||
char* lc_temp = setlocale(posix_locale_category[i], "");
|
||||
category.AssignWithConversion(LocaleList[i]);
|
||||
CopyASCIItoUTF16(LocaleList[i], category);
|
||||
category_platform = category;
|
||||
category_platform.AppendLiteral("##PLATFORM");
|
||||
if (lc_temp != nsnull) {
|
||||
result = posixConverter->GetXPLocale(lc_temp, xpLocale);
|
||||
CopyASCIItoUTF16(lc_temp, platformLocale);
|
||||
} else {
|
||||
char* lang = getenv("LANG");
|
||||
if ( lang == nsnull )
|
||||
if ( lang == nsnull ) {
|
||||
platformLocale.AssignLiteral("en_US");
|
||||
result = posixConverter->GetXPLocale("en-US", xpLocale);
|
||||
else
|
||||
}
|
||||
else {
|
||||
CopyASCIItoUTF16(lang, platformLocale);
|
||||
result = posixConverter->GetXPLocale(lang, xpLocale);
|
||||
}
|
||||
}
|
||||
if (NS_FAILED(result)) {
|
||||
return;
|
||||
}
|
||||
resultLocale->AddCategory(category, xpLocale);
|
||||
resultLocale->AddCategory(category_platform, platformLocale);
|
||||
}
|
||||
mSystemLocale = do_QueryInterface(resultLocale);
|
||||
mApplicationLocale = do_QueryInterface(resultLocale);
|
||||
|
|
|
@ -114,7 +114,7 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale)
|
|||
mLocale.Assign('C');
|
||||
|
||||
nsAutoString localeStr;
|
||||
NS_NAMED_LITERAL_STRING(aCategory, "NSILOCALE_COLLATE");
|
||||
NS_NAMED_LITERAL_STRING(aCategory, "NSILOCALE_COLLATE##PLATFORM");
|
||||
|
||||
// get locale string, use app default if no locale specified
|
||||
if (locale == nsnull) {
|
||||
|
|
|
@ -55,7 +55,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsDateTimeFormatUnix, nsIDateTimeFormat)
|
|||
nsresult nsDateTimeFormatUnix::Initialize(nsILocale* locale)
|
||||
{
|
||||
nsAutoString localeStr;
|
||||
NS_NAMED_LITERAL_STRING(aCategory, "NSILOCALE_TIME");
|
||||
NS_NAMED_LITERAL_STRING(aCategory, "NSILOCALE_TIME##PLATFORM");
|
||||
nsresult res = NS_OK;
|
||||
|
||||
// use cached info if match with stored locale
|
||||
|
|
|
@ -62,7 +62,6 @@
|
|||
#include "nsAutoLock.h"
|
||||
#include "prinit.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsIPosixLocale.h"
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsPlatformCharset, nsIPlatformCharset)
|
||||
|
||||
|
@ -335,12 +334,7 @@ nsPlatformCharset::Init()
|
|||
char* locale = setlocale(LC_CTYPE, nsnull);
|
||||
NS_ASSERTION(locale, "cannot setlocale");
|
||||
if (locale) {
|
||||
nsCOMPtr<nsIPosixLocale> posixConverter =
|
||||
do_GetService(NS_POSIXLOCALE_CONTRACTID);
|
||||
if (posixConverter)
|
||||
res = posixConverter->GetXPLocale(locale, mLocale);
|
||||
if (NS_FAILED(res))
|
||||
return res;
|
||||
CopyASCIItoUTF16(locale, mLocale);
|
||||
} else {
|
||||
mLocale.AssignLiteral("en_US");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче