Bug 422789: reduce narrow windows API calls in uconv/, original patch by Brad Lassey <blassey@mozilla.com>, r=smontagu

This commit is contained in:
Brian Crowder 2008-08-11 15:11:48 -07:00
Родитель 3855ca58b5
Коммит 1f289300fb
1 изменённых файлов: 6 добавлений и 5 удалений

Просмотреть файл

@ -131,9 +131,8 @@ nsPlatformCharset::GetCharset(nsPlatformCharsetSel selector,
NS_IMETHODIMP NS_IMETHODIMP
nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACString& oResult) nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACString& oResult)
{ {
nsCOMPtr<nsIWin32Locale> winLocale; nsCOMPtr<nsIWin32Locale> winLocale;
LCID localeAsLCID; LCID localeAsLCID;
char acp_name[6];
// //
// convert locale name to a code page (through the LCID) // convert locale name to a code page (through the LCID)
@ -147,11 +146,13 @@ nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACS
rv = winLocale->GetPlatformLocale(localeName, &localeAsLCID); rv = winLocale->GetPlatformLocale(localeName, &localeAsLCID);
if (NS_FAILED(rv)) { return rv; } if (NS_FAILED(rv)) { return rv; }
if (GetLocaleInfo(localeAsLCID, LOCALE_IDEFAULTANSICODEPAGE, acp_name, sizeof(acp_name))==0) { PRUnichar acp_name[6];
if (GetLocaleInfoW(localeAsLCID, LOCALE_IDEFAULTANSICODEPAGE, acp_name,
NS_ARRAY_LENGTH(acp_name))==0) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }
nsAutoString acp_key(NS_LITERAL_STRING("acp.")); nsAutoString acp_key(NS_LITERAL_STRING("acp."));
acp_key.AppendWithConversion(acp_name); acp_key.Append(acp_name);
return MapToCharset(acp_key, oResult); return MapToCharset(acp_key, oResult);
} }