summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Cullmann <cullmann@kde.org>2014-01-26 14:15:26 (GMT)
committerChristoph Cullmann <cullmann@kde.org>2014-01-26 14:15:26 (GMT)
commit91e1030a512910d120175bf519c1662a35cff68c (patch)
treeb8bc7e3b7f2384d946bb05b0de76370522ec24ac
parent133c3bdfa157fa492d1bcd552b1d496a556f6768 (diff)
allow detection of encoding by HTML encoding
BUG: 329454
-rw-r--r--src/buffer/katetextloader.h25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/buffer/katetextloader.h b/src/buffer/katetextloader.h
index 86ce5a0..fe7880b 100644
--- a/src/buffer/katetextloader.h
+++ b/src/buffer/katetextloader.h
@@ -243,12 +243,25 @@ public:
/**
* no unicode BOM found, trigger prober
*/
- KEncodingProber prober(m_proberType);
- prober.feed(m_buffer.constData(), c);
-
- // we found codec with some confidence?
- if (prober.confidence() > 0.5) {
- m_codec = QTextCodec::codecForName(prober.encoding());
+
+ /**
+ * first: try to get HTML header encoding
+ */
+ if (QTextCodec *codecForHtml = QTextCodec::codecForHtml (m_buffer, 0)) {
+ m_codec = codecForHtml;
+ }
+
+ /**
+ * else: use KEncodingProber
+ */
+ else {
+ KEncodingProber prober(m_proberType);
+ prober.feed(m_buffer.constData(), c);
+
+ // we found codec with some confidence?
+ if (prober.confidence() > 0.5) {
+ m_codec = QTextCodec::codecForName(prober.encoding());
+ }
}
// no codec, no chance, encoding error