From 1f289300fbd0a6fb788c8f6d254653566bcb423b Mon Sep 17 00:00:00 2001 From: Brian Crowder Date: Mon, 11 Aug 2008 15:11:48 -0700 Subject: [PATCH] Bug 422789: reduce narrow windows API calls in uconv/, original patch by Brad Lassey , r=smontagu --- intl/uconv/src/nsWinCharset.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/intl/uconv/src/nsWinCharset.cpp b/intl/uconv/src/nsWinCharset.cpp index c3eae316a334..b2788c8ac62f 100644 --- a/intl/uconv/src/nsWinCharset.cpp +++ b/intl/uconv/src/nsWinCharset.cpp @@ -131,9 +131,8 @@ nsPlatformCharset::GetCharset(nsPlatformCharsetSel selector, NS_IMETHODIMP nsPlatformCharset::GetDefaultCharsetForLocale(const nsAString& localeName, nsACString& oResult) { - nsCOMPtr winLocale; - LCID localeAsLCID; - char acp_name[6]; + nsCOMPtr winLocale; + LCID localeAsLCID; // // 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); 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; } nsAutoString acp_key(NS_LITERAL_STRING("acp.")); - acp_key.AppendWithConversion(acp_name); + acp_key.Append(acp_name); return MapToCharset(acp_key, oResult); }