diff options
author | Eike Rathke <erack@redhat.com> | 2013-02-13 20:16:42 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-02-15 13:57:27 +0100 |
commit | 8a07032d01aa59fd94c393669d8ac4b8443acb2b (patch) | |
tree | e924ecd3243646df0bf0610fe8cb6e094467d286 /unotools | |
parent | use LanguageTag(rtl_Locale) ctor (diff) | |
download | core-8a07032d01aa59fd94c393669d8ac4b8443acb2b.tar.gz core-8a07032d01aa59fd94c393669d8ac4b8443acb2b.zip |
do not use the raw locale for osl_getTextEncodingFromLocale()
Change-Id: Iab7402721b5fbf20a05c9ff2725e52b012df2940
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/source/misc/syslocale.cxx | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx index d850dd73aab2..bf67a4d2cd6b 100644 --- a/unotools/source/misc/syslocale.cxx +++ b/unotools/source/misc/syslocale.cxx @@ -204,9 +204,21 @@ rtl_TextEncoding SvtSysLocale::GetBestMimeEncoding() { // If the system locale is unknown to us, e.g. LC_ALL=xx, match the UI // language if possible. - ::com::sun::star::lang::Locale aLocale( SvtSysLocale().GetUILanguageTag().getLocale() ); - rtl_Locale * pLocale = rtl_locale_register( aLocale.Language.getStr(), - aLocale.Country.getStr(), aLocale.Variant.getStr() ); + SvtSysLocale aSysLocale; + const LanguageTag& rLanguageTag = aSysLocale.GetUILanguageTag(); + // Converting blindly to Locale and then to rtl_Locale may feed the + // 'qlt' to rtl_locale_register() and the underlying system locale + // stuff, which doesn't know about it nor about BCP47 in the Variant + // field. So use the real language and for non-pure ISO cases hope for + // the best.. the fallback to UTF-8 should solve these cases nowadays. + /* FIXME-BCP47: the script needs to go in here as well, so actually + * we'd need some variant fiddling or glibc locale string and tweak + * rtl_locale_register() to know about it! But then again the Windows + * implementation still wouldn't know anything about it ... */ + SAL_WARN_IF( !rLanguageTag.isIsoLocale(), "unotools.i18n", + "SvtSysLocale::GetBestMimeEncoding - non-ISO UI locale"); + rtl_Locale * pLocale = rtl_locale_register( rLanguageTag.getLanguage().getStr(), + rLanguageTag.getCountry().getStr(), OUString().getStr() ); rtl_TextEncoding nEnc = osl_getTextEncodingFromLocale( pLocale ); pCharSet = rtl_getBestMimeCharsetFromTextEncoding( nEnc ); } |