summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-04-25 13:18:02 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-04-25 13:18:33 +0100
commitd88493adfd549ec77f08ee919df609e645011b8b (patch)
treeaea030de82e8e21231fdd5e516468b16bc16b487 /filter
parent3ba9fd39e3aa74aca63dc2ab475d37b6680e12a8 (diff)
rework GetDefaultTextEncoding etc -> getBestTextEncodingFromLocale
Diffstat (limited to 'filter')
-rw-r--r--filter/inc/filter/msfilter/util.hxx7
-rw-r--r--filter/source/msfilter/util.cxx10
2 files changed, 10 insertions, 7 deletions
diff --git a/filter/inc/filter/msfilter/util.hxx b/filter/inc/filter/msfilter/util.hxx
index 33a66585127c..01ff3738b64a 100644
--- a/filter/inc/filter/msfilter/util.hxx
+++ b/filter/inc/filter/msfilter/util.hxx
@@ -30,13 +30,16 @@
#define INCLUDED_MSFILTER_UTIL_HXX
#include <rtl/textenc.h>
+#include <com/sun/star/lang/Locale.hpp>
#include "filter/msfilter/msfilterdllapi.h"
namespace msfilter {
namespace util {
-/// Returns the default encoding, based on the application's locale.
-MSFILTER_DLLPUBLIC rtl_TextEncoding GetDefaultTextEncoding();
+/// Returns the best-fit default 8bit encoding for a given locale
+/// i.e. useful when dealing with legacy formats which use legacy text encodings without recording
+/// what the encoding is, but you know or can guess the language
+MSFILTER_DLLPUBLIC rtl_TextEncoding getBestTextEncodingFromLocale(const ::com::sun::star::lang::Locale &rLocale);
}
}
diff --git a/filter/source/msfilter/util.cxx b/filter/source/msfilter/util.cxx
index a5fb20933d1d..62edc7fab9de 100644
--- a/filter/source/msfilter/util.cxx
+++ b/filter/source/msfilter/util.cxx
@@ -33,10 +33,11 @@
namespace msfilter {
namespace util {
-rtl_TextEncoding GetDefaultTextEncoding()
+rtl_TextEncoding getBestTextEncodingFromLocale(const ::com::sun::star::lang::Locale &rLocale)
{
- const rtl::OUString& rLanguage = Application::GetSettings().GetLocale().Language;
-
+ //Obviously not comprehensive, feel free to expand these, they're for ultimate fallbacks
+ //in last-ditch broken-file-format cases to guess the right 8bit encodings
+ const rtl::OUString &rLanguage = rLocale.Language;
if (rLanguage == "cs" || rLanguage == "hu" || rLanguage == "pl")
return RTL_TEXTENCODING_MS_1250;
if (rLanguage == "ru" || rLanguage == "uk")
@@ -45,8 +46,7 @@ rtl_TextEncoding GetDefaultTextEncoding()
return RTL_TEXTENCODING_MS_1253;
if (rLanguage == "tr")
return RTL_TEXTENCODING_MS_1254;
- else
- return RTL_TEXTENCODING_MS_1252;
+ return RTL_TEXTENCODING_MS_1252;
}
}