diff options
author | David Tardon <dtardon@redhat.com> | 2014-08-13 16:50:56 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2014-08-13 15:06:45 -0500 |
commit | e11d89ce6404194f7d38c1e8e8f7af62297ca91b (patch) | |
tree | 33782cbae7d67b5c981e895f8ad3c527c4e160e5 | |
parent | bd6048bf5ab668f59a950a41b6bddc5d862cfdce (diff) |
fdo#82418 prefer UTF-8 over UTF-16
Change-Id: Id2c990d24dc942a6d061146ea88cf53ee29a1c3d
(cherry picked from commit a8525fe5cf2ba834ae39e7bfe078911d94957a70)
Reviewed-on: https://gerrit.libreoffice.org/10913
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
-rw-r--r-- | sc/source/ui/dbgui/scuiasciiopt.cxx | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx index 9d6cb86a753e..6fa864d73349 100644 --- a/sc/source/ui/dbgui/scuiasciiopt.cxx +++ b/sc/source/ui/dbgui/scuiasciiopt.cxx @@ -390,8 +390,19 @@ ScImportAsciiDlg::ScImportAsciiDlg( Window* pParent, const OUString& aDatName, // Insert one "SYSTEM" entry for compatibility in AsciiOptions and system // independent document linkage. pLbCharSet->InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, aCharSetUser ); - pLbCharSet->SelectTextEncoding( ePreselectUnicode == RTL_TEXTENCODING_DONTKNOW ? - osl_getThreadTextEncoding() : ePreselectUnicode ); + if ( ePreselectUnicode == RTL_TEXTENCODING_DONTKNOW ) + { + rtl_TextEncoding eSystemEncoding = osl_getThreadTextEncoding(); + // Prefer UTF-8, as UTF-16 would have already been detected from the stream. + // This gives a better chance that the file is going to be opened correctly. + if ( ( eSystemEncoding == RTL_TEXTENCODING_UNICODE ) && mpDatStream ) + eSystemEncoding = RTL_TEXTENCODING_UTF8; + pLbCharSet->SelectTextEncoding( eSystemEncoding ); + } + else + { + pLbCharSet->SelectTextEncoding( ePreselectUnicode ); + } if( nCharSet >= 0 && ePreselectUnicode == RTL_TEXTENCODING_DONTKNOW ) pLbCharSet->SelectEntryPos( static_cast<sal_uInt16>(nCharSet) ); |