https://bugs.documentfoundation.org/show_bug.cgi?id=172905

--- Comment #13 from Julien Nabet <[email protected]> ---
For several character sets, the default confidence is 10.
I propose that if the character set retrieved by DetectEncoding is 10 or less,
we don't use it but rather use osl_getThreadTextEncoding.

So the patch would be:
diff --git a/tools/source/stream/stream.cxx b/tools/source/stream/stream.cxx
index a797b80851d6..25e39e0d0390 100644
--- a/tools/source/stream/stream.cxx
+++ b/tools/source/stream/stream.cxx
@@ -822,6 +822,10 @@ void SvStream::DetectEncoding(size_t maxBytes)
     if (!U_SUCCESS(uerr))
         return;

+    if (ucsdet_getConfidence(match, &uerr) <= 10)
+        return;
+
+
     const char* pEncodingName = ucsdet_getName(match, &uerr);
     if (!U_SUCCESS(uerr) || !pEncodingName)
         return;

Of course, we may rather define a constant instead of a magic number like 10.

In my case, I got RTL_TEXTENCODING_UTF8 and only ° is wrongly detected, the
rest would be ok.

Any thoughts?

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to