commit 6e22e68547b2bac647c5a9c4e2c43eda2dc1c63b Author: Arthur Edelstein arthuredelstein@gmail.com Date: Thu Oct 15 22:10:48 2015 +0000
fixup! Bug #5926: Allow JS locale to be set to English/C.
Fixes #17329: Use the UTF-8 version of the "C" locale to ensure that non-ASCII characters can be typed. --- xpcom/build/XPCOMInit.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/xpcom/build/XPCOMInit.cpp b/xpcom/build/XPCOMInit.cpp index 292652d..ec1f6c9 100644 --- a/xpcom/build/XPCOMInit.cpp +++ b/xpcom/build/XPCOMInit.cpp @@ -520,7 +520,15 @@ void UseUSEnglishLocalePrefChangedCallback(const char* /* pref */, void* /* clos // Read the pref to see if we will use US English locale. bool useUSEnglishLocale = mozilla::Preferences::GetBool(USE_US_ENGLISH_LOCALE_PREF, false); // Set the application-wide C-locale. Needed for Date.toLocaleFormat(). - setlocale(LC_ALL, useUSEnglishLocale ? "C" : sSystemLocale); + if (useUSEnglishLocale) { + // Set the locale to "C.UTF-8" if possible, to avoid interfering with non-ASCII + // keyboard input on some Linux desktops. + // Otherwise fall back to the "C" locale, which is available on all platforms. + // See https://bugs.torproject.org/17329 + setlocale(LC_ALL, "C.UTF-8") || setlocale(LC_ALL, "C"); + } else { + setlocale(LC_ALL, sSystemLocale); + } // Now override the JavaScript Runtime Locale that is used by the Intl API // as well as Date.toLocaleString, Number.toLocaleString, and String.localeCompare. JS_SetDefaultLocale(rt, useUSEnglishLocale ? "en-US" : sJSLocale);