summaryrefslogtreecommitdiff
path: root/unotools/source/misc/syslocale.cxx
diff options
context:
space:
mode:
authorsb <sb@openoffice.org>2010-02-25 12:46:45 +0100
committersb <sb@openoffice.org>2010-02-25 12:46:45 +0100
commitba88d908e6b3379510ed98a5472f1998bde47169 (patch)
tree6bf4020bcf420e329d56fd5c8f7864b82c1b7833 /unotools/source/misc/syslocale.cxx
parent3ce790b86ebe030d549eb5e4543307f2d5416679 (diff)
parentf20bccf2958c070cfa1ec08b20f71bb0f70b8cd1 (diff)
sb118: merged in DEV300_m72
Diffstat (limited to 'unotools/source/misc/syslocale.cxx')
-rw-r--r--unotools/source/misc/syslocale.cxx32
1 files changed, 28 insertions, 4 deletions
diff --git a/unotools/source/misc/syslocale.cxx b/unotools/source/misc/syslocale.cxx
index 8e9d75c6ce0c..f51ef35512cb 100644
--- a/unotools/source/misc/syslocale.cxx
+++ b/unotools/source/misc/syslocale.cxx
@@ -2,13 +2,10 @@
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
- * Copyright 2008 by Sun Microsystems, Inc.
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
- * $RCSfile: syslocale.cxx,v $
- * $Revision: 1.11 $
- *
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
@@ -39,6 +36,9 @@
#include <unotools/localedatawrapper.hxx>
#include <comphelper/processfactory.hxx>
#include <i18npool/mslangid.hxx>
+#include <rtl/tencinfo.h>
+#include <rtl/locale.h>
+#include <osl/nlsupport.h>
using namespace osl;
using namespace com::sun::star;
@@ -187,4 +187,28 @@ LanguageType SvtSysLocale::GetUILanguage() const
return pImpl->aSysLocaleOptions.GetRealUILanguage();
}
+//------------------------------------------------------------------------
+
+// static
+rtl_TextEncoding SvtSysLocale::GetBestMimeEncoding()
+{
+ const sal_Char* pCharSet = rtl_getBestMimeCharsetFromTextEncoding(
+ gsl_getSystemTextEncoding() );
+ if ( !pCharSet )
+ {
+ // 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().GetUILocale() );
+ rtl_Locale * pLocale = rtl_locale_register( aLocale.Language.getStr(),
+ aLocale.Country.getStr(), aLocale.Variant.getStr() );
+ rtl_TextEncoding nEnc = osl_getTextEncodingFromLocale( pLocale );
+ pCharSet = rtl_getBestMimeCharsetFromTextEncoding( nEnc );
+ }
+ rtl_TextEncoding nRet;
+ if ( pCharSet )
+ nRet = rtl_getTextEncodingFromMimeCharset( pCharSet );
+ else
+ nRet = RTL_TEXTENCODING_UTF8;
+ return nRet;
+}