summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
Diffstat (limited to 'sc')
-rw-r--r--sc/source/ui/dbgui/scuiasciiopt.cxx15
1 files changed, 13 insertions, 2 deletions
diff --git a/sc/source/ui/dbgui/scuiasciiopt.cxx b/sc/source/ui/dbgui/scuiasciiopt.cxx
index 512cc5578e3d..a625ecbf6f4f 100644
--- a/sc/source/ui/dbgui/scuiasciiopt.cxx
+++ b/sc/source/ui/dbgui/scuiasciiopt.cxx
@@ -387,8 +387,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) );