Changeset 846 for trunk/src/corelib/codecs
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 22 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/corelib/codecs/codecs.pri
r561 r846 32 32 DEFINES += GNU_LIBICONV 33 33 !mac:LIBS_PRIVATE *= -liconv 34 } else { 34 } else:contains(QT_CONFIG,sun-libiconv) { 35 HEADERS += codecs/qiconvcodec_p.h 36 SOURCES += codecs/qiconvcodec.cpp 37 DEFINES += GNU_LIBICONV 38 } else:!symbian { 35 39 # no iconv, so we put all plugins in the library 36 40 HEADERS += \ … … 53 57 } 54 58 } 59 -
trunk/src/corelib/codecs/codecs.qdoc
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 7 7 ** This file is part of the documentation of the Qt Toolkit. 8 8 ** 9 ** $QT_BEGIN_LICENSE: LGPL$9 ** $QT_BEGIN_LICENSE:L$ 10 10 ** Commercial Usage 11 11 ** Licensees holding valid Qt Commercial licenses may use this file in 12 12 ** accordance with the Qt Commercial License Agreement provided with the 13 ** Software or, alternatively, in accordance with the terms contained in 14 ** awritten agreement between you and Nokia.13 ** Software or, alternatively, in accordance with the terms contained in 14 ** written agreement between you and Nokia. 15 15 ** 16 ** GNU Lesser General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU Lesser 18 ** General Public License version 2.1 as published by the Free Software 19 ** Foundation and appearing in the file LICENSE.LGPL included in the 20 ** packaging of this file. Please review the following information to 21 ** ensure the GNU Lesser General Public License version 2.1 requirements 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 23 ** 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 ** 28 ** GNU General Public License Usage 29 ** Alternatively, this file may be used under the terms of the GNU 30 ** General Public License version 3.0 as published by the Free Software 31 ** Foundation and appearing in the file LICENSE.GPL included in the 32 ** packaging of this file. Please review the following information to 33 ** ensure the GNU General Public License version 3.0 requirements will be 34 ** met: http://www.gnu.org/copyleft/gpl.html. 16 ** GNU Free Documentation License 17 ** Alternatively, this file may be used under the terms of the GNU Free 18 ** Documentation License version 1.3 as published by the Free Software 19 ** Foundation and appearing in the file included in the packaging of this 20 ** file. 35 21 ** 36 22 ** If you have questions regarding the use of this file, please contact -
trunk/src/corelib/codecs/qfontlaocodec.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/src/corelib/codecs/qfontlaocodec_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/src/corelib/codecs/qiconvcodec.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/src/corelib/codecs/qiconvcodec_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/src/corelib/codecs/qisciicodec.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/src/corelib/codecs/qisciicodec_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/src/corelib/codecs/qlatincodec.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/src/corelib/codecs/qlatincodec_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/src/corelib/codecs/qsimplecodec.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 55 55 quint16 values[128]; 56 56 } unicodevalues[QSimpleTextCodec::numSimpleCodecs] = { 57 57 58 // from RFC 1489, ftp://ftp.isi.edu/in-notes/rfc1489.txt 58 59 { "KOI8-R", { "csKOI8R", 0 }, 2084, … … 289 290 0x0175, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x1E6B, 290 291 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x0177, 0x00FF} }, 292 291 293 { "ISO-8859-16", { "iso-ir-226", "latin10", 0 }, 112, 292 294 { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087, … … 310 312 311 313 // $ for a in CP* ; do (awk '/^0x[89ABCDEF]/{ print $1, $2 }' < $a) | sort | sed -e 's/#UNDEF.*$/0xFFFD/' | cut -c6- | paste '-d ' - - - - - - - - | sed -e 's/ /, /g' -e 's/$/,/' -e '$ s/,$/} },/' -e '1 s/^/{ /' > ~/tmp/$a ; done 312 314 #ifndef Q_OS_SYMBIAN 313 315 { "IBM850", { "CP850", "csPC850Multilingual", 0 }, 2009, 314 316 { 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7, … … 345 347 0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57, 346 348 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} }, 349 347 350 { "IBM866", { "CP866", "csIBM866", 0 }, 2086, 348 351 { 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, … … 363 366 0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0} }, 364 367 368 365 369 { "windows-1250", { "CP1250", 0 }, 2250, 366 370 { 0x20AC, 0xFFFD, 0x201A, 0xFFFD, 0x201E, 0x2026, 0x2020, 0x2021, … … 517 521 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF} }, 518 522 523 519 524 { "Apple Roman", { "macintosh", "MacRoman", 0 }, -168, 520 525 { 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1, … … 535 540 0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7} }, 536 541 537 538 539 542 // This one is based on the charmap file 540 543 // /usr/share/i18n/charmaps/SAMI-WS2.gz, which is manually adapted … … 558 561 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF} }, 559 562 560 563 #ifndef Q_OS_SYMBIAN 561 564 // this one is generated from the charmap file located in /usr/share/i18n/charmaps 562 565 // on most Linux distributions. The thai character set tis620 is byte by byte equivalent … … 582 585 0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD } }, 583 586 587 584 588 /* 585 589 Name: hp-roman8 [HP-PCL5,RFC1345,KXS2] -
trunk/src/corelib/codecs/qsimplecodec_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 65 65 { 66 66 public: 67 68 69 67 70 enum { numSimpleCodecs = 30 }; 71 68 72 explicit QSimpleTextCodec(int); 69 73 ~QSimpleTextCodec(); -
trunk/src/corelib/codecs/qtextcodec.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 71 71 # include "qtsciicodec_p.h" 72 72 # include "qisciicodec_p.h" 73 73 74 # if defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED) 74 75 // no iconv(3) support, must build all codecs into the library … … 84 85 # include "../../plugins/codecs/jp/qfontjpcodec.h" 85 86 # endif 87 86 88 #endif // QT_NO_CODECS 87 89 #include "qlocale.h" … … 100 102 #endif 101 103 104 105 106 107 108 102 109 // enabling this is not exception safe! 103 110 // #define Q_DEBUG_TEXTCODEC … … 105 112 QT_BEGIN_NAMESPACE 106 113 107 #if ndef QT_NO_TEXTCODECPLUGIN114 #if 108 115 Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader, 109 116 (QTextCodecFactoryInterface_iid, QLatin1String("/codecs"))) 110 117 #endif 118 119 120 121 111 122 112 123 … … 149 160 static QTextCodec *createForName(const QByteArray &name) 150 161 { 151 #if ndef QT_NO_TEXTCODECPLUGIN162 #if 152 163 QFactoryLoader *l = loader(); 153 164 QStringList keys = l->keys(); … … 181 192 182 193 static QList<QTextCodec*> *all = 0; 183 static int clearCaches = 0; // flags specifying if caches should be invalided: 0x1 codecForName, 0x2 codecForMib184 194 #ifdef Q_DEBUG_TEXTCODEC 185 195 static bool destroying_is_ok = false; … … 413 423 } 414 424 415 QByteArray QWindowsLocalCodec::convertFromUnicode(const QChar *uc, int len, ConverterState *) const 416 { 417 return qt_winQString2MB(uc, len); 425 QByteArray QWindowsLocalCodec::convertFromUnicode(const QChar *ch, int uclen, ConverterState *) const 426 { 427 if (!ch) 428 return QByteArray(); 429 if (uclen == 0) 430 return QByteArray(""); 431 BOOL used_def; 432 QByteArray mb(4096, 0); 433 int len; 434 while (!(len=WideCharToMultiByte(CP_ACP, 0, (const wchar_t*)ch, uclen, 435 mb.data(), mb.size()-1, 0, &used_def))) 436 { 437 int r = GetLastError(); 438 if (r == ERROR_INSUFFICIENT_BUFFER) { 439 mb.resize(1+WideCharToMultiByte(CP_ACP, 0, 440 (const wchar_t*)ch, uclen, 441 0, 0, 0, &used_def)); 442 // and try again... 443 } else { 444 #ifndef QT_NO_DEBUG 445 // Fail. 446 qWarning("WideCharToMultiByte: Cannot convert multibyte text (error %d): %s (UTF-8)", 447 r, QString(ch, uclen).toLocal8Bit().data()); 448 #endif 449 break; 450 } 451 } 452 mb.resize(len); 453 return mb; 418 454 } 419 455 … … 796 832 static void setupLocaleMapper() 797 833 { 834 835 836 837 838 839 798 840 #if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) 799 841 localeMapper = QTextCodec::codecForName("System"); … … 949 991 950 992 #ifndef QT_NO_CODECS 993 994 995 996 997 998 999 1000 1001 1002 1003 951 1004 # if defined(Q_WS_X11) && !defined(QT_BOOTSTRAPPED) 952 1005 // no font codecs when bootstrapping … … 965 1018 # endif // Q_WS_X11 966 1019 967 (void)new QTsciiCodec; 968 969 for (int i = 0; i < 9; ++i) 970 (void)new QIsciiCodec(i); 971 972 1020 1021 #ifndef Q_OS_SYMBIAN 973 1022 # if defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED) 974 1023 // no asian codecs when bootstrapping, sorry … … 984 1033 (void)new QBig5hkscsCodec; 985 1034 # endif // QT_NO_ICONV && !QT_BOOTSTRAPPED 1035 986 1036 #endif // QT_NO_CODECS 987 1037 … … 1000 1050 (void)new QUtf32BECodec; 1001 1051 (void)new QUtf32LECodec; 1052 1002 1053 (void)new QLatin15Codec; 1054 1003 1055 (void)new QLatin1Codec; 1004 1056 (void)new QUtf8Codec; 1005 1057 1006 for (int i = 0; i < QSimpleTextCodec::numSimpleCodecs; ++i) 1007 (void)new QSimpleTextCodec(i); 1008 1058 #ifndef Q_OS_SYMBIAN 1009 1059 #if defined(Q_OS_UNIX) && !defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED) 1010 1060 // QIconvCodec depends on the UTF-16 codec, so it needs to be created last 1011 1061 (void) new QIconvCodec(); 1062 1012 1063 #endif 1013 1064 … … 1047 1098 void qt_resetCodecForLocale() 1048 1099 { 1100 1101 1102 1049 1103 // if QTextCodec::codecForLocale() was called, we assume that the user has 1050 1104 // explicitly set the codec he wants for the locale and don't attempt to … … 1220 1274 #endif 1221 1275 all->removeAll(this); 1222 clearCaches = 0x1 | 0x2; 1276 QTextCodecCache *cache = qTextCodecCache(); 1277 if (cache) 1278 cache->clear(); 1223 1279 } 1224 1280 } … … 1250 1306 return 0; 1251 1307 1252 static QHash <QByteArray, QTextCodec *> cache; 1253 if (clearCaches & 0x1) { 1254 cache.clear(); 1255 clearCaches &= ~0x1; 1256 } 1257 QTextCodec *codec = cache.value(name); 1258 if (codec) 1259 return codec; 1308 QTextCodecCache *cache = qTextCodecCache(); 1309 QTextCodec *codec; 1310 if (cache) { 1311 codec = cache->value(name); 1312 if (codec) 1313 return codec; 1314 } 1260 1315 1261 1316 for (int i = 0; i < all->size(); ++i) { 1262 1317 QTextCodec *cursor = all->at(i); 1263 1318 if (nameMatch(cursor->name(), name)) { 1264 cache.insert(name, cursor); 1319 if (cache) 1320 cache->insert(name, cursor); 1265 1321 return cursor; 1266 1322 } … … 1268 1324 for (int y = 0; y < aliases.size(); ++y) 1269 1325 if (nameMatch(aliases.at(y), name)) { 1270 cache.insert(name, cursor); 1326 if (cache) 1327 cache->insert(name, cursor); 1271 1328 return cursor; 1272 1329 } … … 1274 1331 1275 1332 codec = createForName(name); 1276 if (codec )1277 cache .insert(name, codec);1333 if (codec) 1334 cacheinsert(name, codec); 1278 1335 return codec; 1279 1336 } … … 1294 1351 return 0; 1295 1352 1296 static QHash <int, QTextCodec *> cache; 1297 if (clearCaches & 0x2) { 1298 cache.clear(); 1299 clearCaches &= ~0x2; 1300 } 1301 QTextCodec *codec = cache.value(mib); 1302 if (codec) 1303 return codec; 1353 QByteArray key = "MIB: " + QByteArray::number(mib); 1354 QTextCodecCache *cache = qTextCodecCache(); 1355 QTextCodec *codec; 1356 if (cache) 1357 codec = cache->value(key); 1304 1358 1305 1359 QList<QTextCodec*>::ConstIterator i; … … 1307 1361 QTextCodec *cursor = all->at(i); 1308 1362 if (cursor->mibEnum() == mib) { 1309 cache.insert(mib, cursor); 1363 if (cache) 1364 cache->insert(key, cursor); 1310 1365 return cursor; 1311 1366 } … … 1319 1374 return codecForMib(1015); 1320 1375 1321 if (codec )1322 cache .insert(mib, codec);1376 if (codec) 1377 cache, codec); 1323 1378 return codec; 1324 1379 } … … 1354 1409 #endif 1355 1410 1356 #if ndef QT_NO_TEXTCODECPLUGIN1411 #if 1357 1412 QFactoryLoader *l = loader(); 1358 1413 QStringList keys = l->keys(); … … 1394 1449 #endif 1395 1450 1396 #if ndef QT_NO_TEXTCODECPLUGIN1451 #if 1397 1452 QFactoryLoader *l = loader(); 1398 1453 QStringList keys = l->keys(); … … 1421 1476 void QTextCodec::setCodecForLocale(QTextCodec *c) 1422 1477 { 1478 1479 1480 1423 1481 codecForLocaleSet = true; 1424 1482 localeMapper = c; … … 1528 1586 } 1529 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1530 1601 1531 1602 /*! … … 1538 1609 { 1539 1610 return new QTextEncoder(this); 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1540 1624 } 1541 1625 … … 1679 1763 Constructs a text encoder for the given \a codec. 1680 1764 */ 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1681 1776 1682 1777 /*! … … 1755 1850 Constructs a text decoder for the given \a codec. 1756 1851 */ 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1757 1864 1758 1865 /*! -
trunk/src/corelib/codecs/qtextcodec.h
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 86 86 static QTextCodec *codecForUtfText(const QByteArray &ba, QTextCodec *defaultCodec); 87 87 88 QTextDecoder* makeDecoder() const;89 QTextEncoder* makeEncoder() const;90 91 88 bool canEncode(QChar) const; 92 89 bool canEncode(const QString&) const; … … 120 117 QByteArray fromUnicode(const QChar *in, int length, ConverterState *state = 0) const 121 118 { return convertFromUnicode(in, length, state); } 119 120 121 122 123 124 122 125 123 126 virtual QByteArray name() const = 0; … … 159 162 public: 160 163 explicit QTextEncoder(const QTextCodec *codec) : c(codec), state() {} 164 161 165 ~QTextEncoder(); 162 166 QByteArray fromUnicode(const QString& str); … … 169 173 const QTextCodec *c; 170 174 QTextCodec::ConverterState state; 171 172 friend class QXmlStreamWriter;173 friend class QXmlStreamWriterPrivate;174 #if defined(Q_OS_MAC32) || defined(Q_OS_AIX)175 friend class QCoreXmlStreamWriter;176 friend class QCoreXmlStreamWriterPrivate;177 #endif178 175 }; 179 176 … … 182 179 public: 183 180 explicit QTextDecoder(const QTextCodec *codec) : c(codec), state() {} 181 184 182 ~QTextDecoder(); 185 183 QString toUnicode(const char* chars, int len); -
trunk/src/corelib/codecs/qtextcodec_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/src/corelib/codecs/qtextcodecplugin.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/src/corelib/codecs/qtextcodecplugin.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/src/corelib/codecs/qtsciicodec.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/src/corelib/codecs/qtsciicodec_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/src/corelib/codecs/qutfcodec.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 48 48 49 49 enum { Endian = 0, Data = 1 }; 50 51 52 53 54 55 56 57 58 59 60 61 62 50 63 51 64 QByteArray QUtf8::convertFromUnicode(const QChar *uc, int len, QTextCodec::ConverterState *state) … … 107 120 *cursor++ = 0xc0 | ((uchar) (u >> 6)); 108 121 } else { 122 123 124 125 126 127 128 129 109 130 if (u > 0xffff) { 110 // see QString::fromUtf8() and QString::utf8() for explanations 111 if (u > 0x10fe00 && u < 0x10ff00) { 112 *cursor++ = (u - 0x10fe00); 113 ++ch; 114 continue; 115 } else { 116 *cursor++ = 0xf0 | ((uchar) (u >> 18)); 117 *cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f); 118 } 131 *cursor++ = 0xf0 | ((uchar) (u >> 18)); 132 *cursor++ = 0x80 | (((uchar) (u >> 12)) & 0x3f); 119 133 } else { 120 134 *cursor++ = 0xe0 | (((uchar) (u >> 12)) & 0x3f); … … 180 194 if (!need) { 181 195 // utf-8 bom composes into 0xfeff code point 196 182 197 if (!headerdone && uc == 0xfeff) { 183 // don t do anything, just skip the BOM184 } else if ( uc > 0xffff && uc < 0x110000) {198 // dont do anything, just skip the BOM 199 } else if (uc > 0xffff && uc < 0x110000) { 185 200 // surrogate pair 186 201 Q_ASSERT((qch - (ushort*)result.unicode()) + 2 < result.length()); 187 202 *qch++ = QChar::highSurrogate(uc); 188 203 *qch++ = QChar::lowSurrogate(uc); 189 } else if ((uc < min_uc) || (uc >= 0xd800 && uc <= 0xdfff) || (uc >= 0xfffe)) {190 // error: overlong sequence, UTF16 surrogate or BOM204 } else if ((uc < min_uc) || (uc >= 0xd800 && uc <= 0xdfff) || ) { 205 // error: overlong sequence, UTF16 surrogate or 191 206 *qch++ = replacement; 192 207 ++invalid; -
trunk/src/corelib/codecs/qutfcodec_p.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected])
Note:
See TracChangeset
for help on using the changeset viewer.