summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-04-29 08:59:37 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-05-04 13:34:12 (GMT)
commita7b9c4e332dd03ab17a4d8f520fef95f5daeebe4 (patch)
tree644ea6e69346605978d46476c183f25c3792eb0c /src/corelib/io
parent7031e1d110bb1bc97cfe0377adc211030e1e7320 (diff)
downloadQt-a7b9c4e332dd03ab17a4d8f520fef95f5daeebe4.zip
Qt-a7b9c4e332dd03ab17a4d8f520fef95f5daeebe4.tar.gz
Qt-a7b9c4e332dd03ab17a4d8f520fef95f5daeebe4.tar.bz2
Use the new QTextCodec::codecForUtfText in qtextstream to detect the
utf encoding by BOM. Reviewed-by: Simon Hausmann
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qtextstream.cpp9
1 files changed, 2 insertions, 7 deletions
diff --git a/src/corelib/io/qtextstream.cpp b/src/corelib/io/qtextstream.cpp
index 73408dc..3c015da 100644
--- a/src/corelib/io/qtextstream.cpp
+++ b/src/corelib/io/qtextstream.cpp
@@ -559,13 +559,8 @@ bool QTextStreamPrivate::fillReadBuffer(qint64 maxBytes)
if (!codec || autoDetectUnicode) {
autoDetectUnicode = false;
- if (bytesRead >= 4 && ((uchar(buf[0]) == 0xff && uchar(buf[1]) == 0xfe && uchar(buf[2]) == 0 && uchar(buf[3]) == 0)
- || (uchar(buf[0]) == 0 && uchar(buf[1]) == 0 && uchar(buf[2]) == 0xfe && uchar(buf[3]) == 0xff))) {
- codec = QTextCodec::codecForName("UTF-32");
- } else if (bytesRead >= 2 && ((uchar(buf[0]) == 0xff && uchar(buf[1]) == 0xfe)
- || (uchar(buf[0]) == 0xfe && uchar(buf[1]) == 0xff))) {
- codec = QTextCodec::codecForName("UTF-16");
- } else if (!codec) {
+ codec = QTextCodec::codecForUtfText(QByteArray::fromRawData(buf, bytesRead), 0);
+ if (!codec) {
codec = QTextCodec::codecForLocale();
writeConverterState.flags |= QTextCodec::IgnoreHeader;
}