Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
22 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/corelib/codecs/codecs.pri

    r561 r846  
    3232                DEFINES += GNU_LIBICONV
    3333                !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 {
    3539                # no iconv, so we put all plugins in the library
    3640                HEADERS += \
     
    5357        }
    5458}
     59
  • trunk/src/corelib/codecs/codecs.qdoc

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    77** This file is part of the documentation of the Qt Toolkit.
    88**
    9 ** $QT_BEGIN_LICENSE:LGPL$
     9** $QT_BEGIN_LICENSE:L$
    1010** Commercial Usage
    1111** Licensees holding valid Qt Commercial licenses may use this file in
    1212** accordance with the Qt Commercial License Agreement provided with the
    13 ** Software or, alternatively, in accordance with the terms contained in
    14 ** a written agreement between you and Nokia.
     13** Software or, alternatively, in accordance with the terms contained in
     14** written agreement between you and Nokia.
    1515**
    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.
    3521**
    3622** If you have questions regarding the use of this file, please contact
  • trunk/src/corelib/codecs/qfontlaocodec.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/src/corelib/codecs/qfontlaocodec_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/src/corelib/codecs/qiconvcodec.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/src/corelib/codecs/qiconvcodec_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/src/corelib/codecs/qisciicodec.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/src/corelib/codecs/qisciicodec_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/src/corelib/codecs/qlatincodec.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/src/corelib/codecs/qlatincodec_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/src/corelib/codecs/qsimplecodec.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    5555    quint16 values[128];
    5656} unicodevalues[QSimpleTextCodec::numSimpleCodecs] = {
     57
    5758    // from RFC 1489, ftp://ftp.isi.edu/in-notes/rfc1489.txt
    5859    { "KOI8-R", { "csKOI8R", 0 }, 2084,
     
    289290        0x0175, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x1E6B,
    290291        0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x0177, 0x00FF} },
     292
    291293    { "ISO-8859-16", { "iso-ir-226", "latin10", 0 }, 112,
    292294      { 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
     
    310312
    311313    // $ 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
    313315    { "IBM850", { "CP850", "csPC850Multilingual", 0 }, 2009,
    314316      { 0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
     
    345347        0x0E50, 0x0E51, 0x0E52, 0x0E53, 0x0E54, 0x0E55, 0x0E56, 0x0E57,
    346348        0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD} },
     349
    347350    { "IBM866", { "CP866", "csIBM866", 0 }, 2086,
    348351      { 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
     
    363366        0x00B0, 0x2219, 0x00B7, 0x221A, 0x2116, 0x00A4, 0x25A0, 0x00A0} },
    364367
     368
    365369    { "windows-1250", { "CP1250", 0 }, 2250,
    366370      { 0x20AC, 0xFFFD, 0x201A, 0xFFFD, 0x201E, 0x2026, 0x2020, 0x2021,
     
    517521        0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x01B0, 0x20AB, 0x00FF} },
    518522
     523
    519524    { "Apple Roman", { "macintosh", "MacRoman", 0 }, -168,
    520525      { 0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1,
     
    535540        0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7} },
    536541
    537 
    538 
    539542    // This one is based on the charmap file
    540543    // /usr/share/i18n/charmaps/SAMI-WS2.gz, which is manually adapted
     
    558561        0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF} },
    559562
    560 
     563#ifndef Q_OS_SYMBIAN
    561564    // this one is generated from the charmap file located in /usr/share/i18n/charmaps
    562565    // on most Linux distributions. The thai character set tis620 is byte by byte equivalent
     
    582585        0x0E58, 0x0E59, 0x0E5A, 0x0E5B, 0xFFFD, 0xFFFD, 0xFFFD, 0xFFFD } },
    583586
     587
    584588    /*
    585589      Name: hp-roman8                                  [HP-PCL5,RFC1345,KXS2]
  • trunk/src/corelib/codecs/qsimplecodec_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    6565{
    6666public:
     67
     68
     69
    6770    enum { numSimpleCodecs = 30 };
     71
    6872    explicit QSimpleTextCodec(int);
    6973    ~QSimpleTextCodec();
  • trunk/src/corelib/codecs/qtextcodec.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    7171#  include "qtsciicodec_p.h"
    7272#  include "qisciicodec_p.h"
     73
    7374#  if defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
    7475// no iconv(3) support, must build all codecs into the library
     
    8485#    include "../../plugins/codecs/jp/qfontjpcodec.h"
    8586#  endif
     87
    8688#endif // QT_NO_CODECS
    8789#include "qlocale.h"
     
    100102#endif
    101103
     104
     105
     106
     107
     108
    102109// enabling this is not exception safe!
    103110// #define Q_DEBUG_TEXTCODEC
     
    105112QT_BEGIN_NAMESPACE
    106113
    107 #ifndef QT_NO_TEXTCODECPLUGIN
     114#if
    108115Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
    109116    (QTextCodecFactoryInterface_iid, QLatin1String("/codecs")))
    110117#endif
     118
     119
     120
     121
    111122
    112123
     
    149160static QTextCodec *createForName(const QByteArray &name)
    150161{
    151 #ifndef QT_NO_TEXTCODECPLUGIN
     162#if
    152163    QFactoryLoader *l = loader();
    153164    QStringList keys = l->keys();
     
    181192
    182193static QList<QTextCodec*> *all = 0;
    183 static int clearCaches = 0;  // flags specifying if caches should be invalided: 0x1 codecForName, 0x2 codecForMib
    184194#ifdef Q_DEBUG_TEXTCODEC
    185195static bool destroying_is_ok = false;
     
    413423}
    414424
    415 QByteArray QWindowsLocalCodec::convertFromUnicode(const QChar *uc, int len, ConverterState *) const
    416 {
    417     return qt_winQString2MB(uc, len);
     425QByteArray 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;
    418454}
    419455
     
    796832static void setupLocaleMapper()
    797833{
     834
     835
     836
     837
     838
     839
    798840#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
    799841    localeMapper = QTextCodec::codecForName("System");
     
    949991
    950992#ifndef QT_NO_CODECS
     993
     994
     995
     996
     997
     998
     999
     1000
     1001
     1002
     1003
    9511004#  if defined(Q_WS_X11) && !defined(QT_BOOTSTRAPPED)
    9521005    // no font codecs when bootstrapping
     
    9651018#  endif // Q_WS_X11
    9661019
    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
    9731022#  if defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
    9741023    // no asian codecs when bootstrapping, sorry
     
    9841033    (void)new QBig5hkscsCodec;
    9851034#  endif // QT_NO_ICONV && !QT_BOOTSTRAPPED
     1035
    9861036#endif // QT_NO_CODECS
    9871037
     
    10001050    (void)new QUtf32BECodec;
    10011051    (void)new QUtf32LECodec;
     1052
    10021053    (void)new QLatin15Codec;
     1054
    10031055    (void)new QLatin1Codec;
    10041056    (void)new QUtf8Codec;
    10051057
    1006     for (int i = 0; i < QSimpleTextCodec::numSimpleCodecs; ++i)
    1007         (void)new QSimpleTextCodec(i);
    1008 
     1058#ifndef Q_OS_SYMBIAN
    10091059#if defined(Q_OS_UNIX) && !defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
    10101060    // QIconvCodec depends on the UTF-16 codec, so it needs to be created last
    10111061    (void) new QIconvCodec();
     1062
    10121063#endif
    10131064
     
    10471098void qt_resetCodecForLocale()
    10481099{
     1100
     1101
     1102
    10491103    // if QTextCodec::codecForLocale() was called, we assume that the user has
    10501104    // explicitly set the codec he wants for the locale and don't attempt to
     
    12201274#endif
    12211275        all->removeAll(this);
    1222         clearCaches = 0x1 | 0x2;
     1276        QTextCodecCache *cache = qTextCodecCache();
     1277        if (cache)
     1278            cache->clear();
    12231279    }
    12241280}
     
    12501306        return 0;
    12511307
    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    }
    12601315
    12611316    for (int i = 0; i < all->size(); ++i) {
    12621317        QTextCodec *cursor = all->at(i);
    12631318        if (nameMatch(cursor->name(), name)) {
    1264             cache.insert(name, cursor);
     1319            if (cache)
     1320                cache->insert(name, cursor);
    12651321            return cursor;
    12661322        }
     
    12681324        for (int y = 0; y < aliases.size(); ++y)
    12691325            if (nameMatch(aliases.at(y), name)) {
    1270                 cache.insert(name, cursor);
     1326                if (cache)
     1327                    cache->insert(name, cursor);
    12711328                return cursor;
    12721329            }
     
    12741331
    12751332    codec = createForName(name);
    1276     if (codec)
    1277         cache.insert(name, codec);
     1333    if (codec)
     1334        cacheinsert(name, codec);
    12781335    return codec;
    12791336}
     
    12941351        return 0;
    12951352
    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);
    13041358
    13051359    QList<QTextCodec*>::ConstIterator i;
     
    13071361        QTextCodec *cursor = all->at(i);
    13081362        if (cursor->mibEnum() == mib) {
    1309             cache.insert(mib, cursor);
     1363            if (cache)
     1364                cache->insert(key, cursor);
    13101365            return cursor;
    13111366        }
     
    13191374        return codecForMib(1015);
    13201375
    1321     if (codec)
    1322         cache.insert(mib, codec);
     1376    if (codec)
     1377        cache, codec);
    13231378    return codec;
    13241379}
     
    13541409#endif
    13551410
    1356 #ifndef QT_NO_TEXTCODECPLUGIN
     1411#if
    13571412    QFactoryLoader *l = loader();
    13581413    QStringList keys = l->keys();
     
    13941449#endif
    13951450
    1396 #ifndef QT_NO_TEXTCODECPLUGIN
     1451#if
    13971452    QFactoryLoader *l = loader();
    13981453    QStringList keys = l->keys();
     
    14211476void QTextCodec::setCodecForLocale(QTextCodec *c)
    14221477{
     1478
     1479
     1480
    14231481    codecForLocaleSet = true;
    14241482    localeMapper = c;
     
    15281586}
    15291587
     1588
     1589
     1590
     1591
     1592
     1593
     1594
     1595
     1596
     1597
     1598
     1599
     1600
    15301601
    15311602/*!
     
    15381609{
    15391610    return new QTextEncoder(this);
     1611
     1612
     1613
     1614
     1615
     1616
     1617
     1618
     1619
     1620
     1621
     1622
     1623
    15401624}
    15411625
     
    16791763    Constructs a text encoder for the given \a codec.
    16801764*/
     1765
     1766
     1767
     1768
     1769
     1770
     1771
     1772
     1773
     1774
     1775
    16811776
    16821777/*!
     
    17551850    Constructs a text decoder for the given \a codec.
    17561851*/
     1852
     1853
     1854
     1855
     1856
     1857
     1858
     1859
     1860
     1861
     1862
     1863
    17571864
    17581865/*!
  • trunk/src/corelib/codecs/qtextcodec.h

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    8686    static QTextCodec *codecForUtfText(const QByteArray &ba, QTextCodec *defaultCodec);
    8787
    88     QTextDecoder* makeDecoder() const;
    89     QTextEncoder* makeEncoder() const;
    90 
    9188    bool canEncode(QChar) const;
    9289    bool canEncode(const QString&) const;
     
    120117    QByteArray fromUnicode(const QChar *in, int length, ConverterState *state = 0) const
    121118        { return convertFromUnicode(in, length, state); }
     119
     120
     121
     122
     123
     124
    122125
    123126    virtual QByteArray name() const = 0;
     
    159162public:
    160163    explicit QTextEncoder(const QTextCodec *codec) : c(codec), state() {}
     164
    161165    ~QTextEncoder();
    162166    QByteArray fromUnicode(const QString& str);
     
    169173    const QTextCodec *c;
    170174    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 #endif
    178175};
    179176
     
    182179public:
    183180    explicit QTextDecoder(const QTextCodec *codec) : c(codec), state() {}
     181
    184182    ~QTextDecoder();
    185183    QString toUnicode(const char* chars, int len);
  • trunk/src/corelib/codecs/qtextcodec_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/src/corelib/codecs/qtextcodecplugin.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/src/corelib/codecs/qtextcodecplugin.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/src/corelib/codecs/qtsciicodec.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/src/corelib/codecs/qtsciicodec_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
  • trunk/src/corelib/codecs/qutfcodec.cpp

    r769 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
     
    4848
    4949enum { Endian = 0, Data = 1 };
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
    5063
    5164QByteArray QUtf8::convertFromUnicode(const QChar *uc, int len, QTextCodec::ConverterState *state)
     
    107120                *cursor++ = 0xc0 | ((uchar) (u >> 6));
    108121            } else {
     122
     123
     124
     125
     126
     127
     128
     129
    109130                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);
    119133                } else {
    120134                    *cursor++ = 0xe0 | (((uchar) (u >> 12)) & 0x3f);
     
    180194                if (!need) {
    181195                    // utf-8 bom composes into 0xfeff code point
     196
    182197                    if (!headerdone && uc == 0xfeff) {
    183                         // dont do anything, just skip the BOM
    184                     } else if (uc > 0xffff && uc < 0x110000) {
     198                        // dont do anything, just skip the BOM
     199                    } else if (uc > 0xffff && uc < 0x110000) {
    185200                        // surrogate pair
    186201                        Q_ASSERT((qch - (ushort*)result.unicode()) + 2 < result.length());
    187202                        *qch++ = QChar::highSurrogate(uc);
    188203                        *qch++ = QChar::lowSurrogate(uc);
    189                     } else if ((uc < min_uc) || (uc >= 0xd800 && uc <= 0xdfff) || (uc >= 0xfffe)) {
    190                         // error: overlong sequence, UTF16 surrogate or BOM
     204                    } else if ((uc < min_uc) || (uc >= 0xd800 && uc <= 0xdfff) || ) {
     205                        // error: overlong sequence, UTF16 surrogate or
    191206                        *qch++ = replacement;
    192207                        ++invalid;
  • trunk/src/corelib/codecs/qutfcodec_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation ([email protected])
Note: See TracChangeset for help on using the changeset viewer.