| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/codecs/qtsciicodec.cpp | 
| Source code | Switch to Preprocessed file | 
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
| 24 | ** | - | ||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
| 35 | ** | - | ||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 37 | ** | - | ||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | // Most of the code here was originally written by Hans Petter Bieker, | - | ||||||||||||
| 41 | // and is included in Qt with the author's permission, and the grateful | - | ||||||||||||
| 42 | // thanks of the Qt team. | - | ||||||||||||
| 43 | - | |||||||||||||
| 44 | #include "qtsciicodec_p.h" | - | ||||||||||||
| 45 | #include "qlist.h" | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | #ifndef QT_NO_CODECS | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | static unsigned char qt_UnicodeToTSCII(ushort u1, ushort u2, ushort u3); | - | ||||||||||||
| 52 | static unsigned int qt_TSCIIToUnicode(unsigned int code, uint *s); | - | ||||||||||||
| 53 | - | |||||||||||||
| 54 | #define IsTSCIIChar(c) (((c) >= 0x80) && ((c) <= 0xfd)) | - | ||||||||||||
| 55 | - | |||||||||||||
| 56 | /*! \class QTsciiCodec | - | ||||||||||||
| 57 | \inmodule QtCore | - | ||||||||||||
| 58 | \reentrant | - | ||||||||||||
| 59 | \internal | - | ||||||||||||
| 60 | */ | - | ||||||||||||
| 61 | - | |||||||||||||
| 62 | /*! | - | ||||||||||||
| 63 | Destroys the text codec object. | - | ||||||||||||
| 64 | */ | - | ||||||||||||
| 65 | QTsciiCodec::~QTsciiCodec() | - | ||||||||||||
| 66 | { | - | ||||||||||||
| 67 | } | - | ||||||||||||
| 68 | - | |||||||||||||
| 69 | /*! | - | ||||||||||||
| 70 | Converts the first \a len characters in \a uc from Unicode to this | - | ||||||||||||
| 71 | encoding, and returns the result in a byte array. The \a state contains | - | ||||||||||||
| 72 | some conversion flags, and is used by the codec to maintain state | - | ||||||||||||
| 73 | information. | - | ||||||||||||
| 74 | */ | - | ||||||||||||
| 75 | QByteArray QTsciiCodec::convertFromUnicode(const QChar *uc, int len, ConverterState *state) const | - | ||||||||||||
| 76 | { | - | ||||||||||||
| 77 | char replacement = '?'; | - | ||||||||||||
| 78 | if (state) { 
 | 0-3 | ||||||||||||
| 79 | if (state->flags & ConvertInvalidToNull) 
 | 0 | ||||||||||||
| 80 | replacement = 0; never executed:  replacement = 0; | 0 | ||||||||||||
| 81 | } never executed:  end of block | 0 | ||||||||||||
| 82 | int invalid = 0; | - | ||||||||||||
| 83 | - | |||||||||||||
| 84 | QByteArray rstr(len, Qt::Uninitialized); | - | ||||||||||||
| 85 | uchar* cursor = (uchar*)rstr.data(); | - | ||||||||||||
| 86 | for (int i = 0; i < len; i++) { 
 | 3-12 | ||||||||||||
| 87 | QChar ch = uc[i]; | - | ||||||||||||
| 88 | uchar j; | - | ||||||||||||
| 89 | if (ch.row() == 0x00 && ch.cell() < 0x80) { 
 
 | 0-12 | ||||||||||||
| 90 | // ASCII | - | ||||||||||||
| 91 | j = ch.cell(); | - | ||||||||||||
| 92 | } else if ((j = qt_UnicodeToTSCII(uc[i].unicode(), executed 12 times by 1 test:  end of blockExecuted by: 
 
 | 0-12 | ||||||||||||
| 93 | uc[i + 1].unicode(), 
 | 0 | ||||||||||||
| 94 | uc[i + 2].unicode()))) { 
 | 0 | ||||||||||||
| 95 | // We have to check the combined chars first! | - | ||||||||||||
| 96 | i += 2; | - | ||||||||||||
| 97 | } else if ((j = qt_UnicodeToTSCII(uc[i].unicode(), never executed:  end of block
 | 0 | ||||||||||||
| 98 | uc[i + 1].unicode(), 0))) { 
 | 0 | ||||||||||||
| 99 | i++; | - | ||||||||||||
| 100 | } else if ((j = qt_UnicodeToTSCII(uc[i].unicode(), 0, 0))) { never executed:  end of block
 | 0 | ||||||||||||
| 101 | } else { never executed:  end of block | 0 | ||||||||||||
| 102 | // Error | - | ||||||||||||
| 103 | j = replacement; | - | ||||||||||||
| 104 | ++invalid; | - | ||||||||||||
| 105 | } never executed:  end of block | 0 | ||||||||||||
| 106 | *cursor++ = j; | - | ||||||||||||
| 107 | } executed 12 times by 1 test:  end of blockExecuted by: 
 | 12 | ||||||||||||
| 108 | rstr.resize(cursor - (const uchar*)rstr.constData()); | - | ||||||||||||
| 109 | - | |||||||||||||
| 110 | if (state) { 
 | 0-3 | ||||||||||||
| 111 | state->invalidChars += invalid; | - | ||||||||||||
| 112 | } never executed:  end of block | 0 | ||||||||||||
| 113 | return rstr; executed 3 times by 1 test:  return rstr;Executed by: 
 | 3 | ||||||||||||
| 114 | } | - | ||||||||||||
| 115 | - | |||||||||||||
| 116 | /*! | - | ||||||||||||
| 117 | Converts the first \a len characters in \a chars from this encoding | - | ||||||||||||
| 118 | to Unicode, and returns the result in a QString. The \a state contains | - | ||||||||||||
| 119 | some conversion flags, and is used by the codec to maintain state | - | ||||||||||||
| 120 | information. | - | ||||||||||||
| 121 | */ | - | ||||||||||||
| 122 | QString QTsciiCodec::convertToUnicode(const char* chars, int len, ConverterState *state) const | - | ||||||||||||
| 123 | { | - | ||||||||||||
| 124 | QChar replacement = QChar::ReplacementCharacter; | - | ||||||||||||
| 125 | if (state) { 
 | 0-2 | ||||||||||||
| 126 | if (state->flags & ConvertInvalidToNull) 
 | 0 | ||||||||||||
| 127 | replacement = QChar::Null; never executed:  replacement = QChar::Null; | 0 | ||||||||||||
| 128 | } never executed:  end of block | 0 | ||||||||||||
| 129 | int invalid = 0; | - | ||||||||||||
| 130 | - | |||||||||||||
| 131 | QString result; | - | ||||||||||||
| 132 | for (int i = 0; i < len; i++) { 
 | 2-9 | ||||||||||||
| 133 | uchar ch = chars[i]; | - | ||||||||||||
| 134 | if (ch < 0x80) { 
 | 0-9 | ||||||||||||
| 135 | // ASCII | - | ||||||||||||
| 136 | result += QLatin1Char(ch); | - | ||||||||||||
| 137 | } else if (IsTSCIIChar(ch)) { executed 9 times by 1 test:  end of blockExecuted by: 
 
 
 | 0-9 | ||||||||||||
| 138 | // TSCII | - | ||||||||||||
| 139 | uint s[3]; | - | ||||||||||||
| 140 | uint u = qt_TSCIIToUnicode(ch, s); | - | ||||||||||||
| 141 | uint *p = s; | - | ||||||||||||
| 142 | while (u--) { 
 | 0 | ||||||||||||
| 143 | uint c = *p++; | - | ||||||||||||
| 144 | if (c) 
 | 0 | ||||||||||||
| 145 | result += QChar(c); never executed:  result += QChar(c); | 0 | ||||||||||||
| 146 | else { | - | ||||||||||||
| 147 | result += replacement; | - | ||||||||||||
| 148 | ++invalid; | - | ||||||||||||
| 149 | } never executed:  end of block | 0 | ||||||||||||
| 150 | } | - | ||||||||||||
| 151 | } else { never executed:  end of block | 0 | ||||||||||||
| 152 | // Invalid | - | ||||||||||||
| 153 | result += replacement; | - | ||||||||||||
| 154 | ++invalid; | - | ||||||||||||
| 155 | } never executed:  end of block | 0 | ||||||||||||
| 156 | } | - | ||||||||||||
| 157 | - | |||||||||||||
| 158 | if (state) { 
 | 0-2 | ||||||||||||
| 159 | state->invalidChars += invalid; | - | ||||||||||||
| 160 | } never executed:  end of block | 0 | ||||||||||||
| 161 | return result; executed 2 times by 1 test:  return result;Executed by: 
 | 2 | ||||||||||||
| 162 | } | - | ||||||||||||
| 163 | - | |||||||||||||
| 164 | /*! | - | ||||||||||||
| 165 | Returns the official name for the encoding that is handled by the codec. | - | ||||||||||||
| 166 | - | |||||||||||||
| 167 | \sa QTextCodec::name() | - | ||||||||||||
| 168 | */ | - | ||||||||||||
| 169 | QByteArray QTsciiCodec::name() const | - | ||||||||||||
| 170 | { | - | ||||||||||||
| 171 | return "TSCII"; executed 27 times by 1 test:  return "TSCII";Executed by: 
 | 27 | ||||||||||||
| 172 | } | - | ||||||||||||
| 173 | - | |||||||||||||
| 174 | /*! | - | ||||||||||||
| 175 | Returns the MIB enum for the encoding. | - | ||||||||||||
| 176 | - | |||||||||||||
| 177 | \sa QTextCodec::mibEnum() | - | ||||||||||||
| 178 | */ | - | ||||||||||||
| 179 | int QTsciiCodec::mibEnum() const | - | ||||||||||||
| 180 | { | - | ||||||||||||
| 181 | return 2107; executed 113 times by 1 test:  return 2107;Executed by: 
 | 113 | ||||||||||||
| 182 | } | - | ||||||||||||
| 183 | - | |||||||||||||
| 184 | static const int UnToTsLast = 124; // 125 items -- so the last will be 124 | - | ||||||||||||
| 185 | static const ushort UnToTs [][4] = { | - | ||||||||||||
| 186 | // *Sorted* list of TSCII maping for unicode chars | - | ||||||||||||
| 187 | //FIRST SECOND THIRD TSCII | - | ||||||||||||
| 188 | {0x00A0, 0x0000, 0x0000, 0xA0}, | - | ||||||||||||
| 189 | {0x00A9, 0x0000, 0x0000, 0xA9}, | - | ||||||||||||
| 190 | {0x0B83, 0x0000, 0x0000, 0xB7}, | - | ||||||||||||
| 191 | {0x0B85, 0x0000, 0x0000, 0xAB}, | - | ||||||||||||
| 192 | {0x0B86, 0x0000, 0x0000, 0xAC}, | - | ||||||||||||
| 193 | {0x0B87, 0x0000, 0x0000, 0xAD}, | - | ||||||||||||
| 194 | {0x0B88, 0x0000, 0x0000, 0xAE}, | - | ||||||||||||
| 195 | {0x0B89, 0x0000, 0x0000, 0xAF}, | - | ||||||||||||
| 196 | {0x0B8A, 0x0000, 0x0000, 0xB0}, | - | ||||||||||||
| 197 | {0x0B8E, 0x0000, 0x0000, 0xB1}, | - | ||||||||||||
| 198 | {0x0B8F, 0x0000, 0x0000, 0xB2}, | - | ||||||||||||
| 199 | {0x0B90, 0x0000, 0x0000, 0xB3}, | - | ||||||||||||
| 200 | {0x0B92, 0x0000, 0x0000, 0xB4}, | - | ||||||||||||
| 201 | {0x0B93, 0x0000, 0x0000, 0xB5}, | - | ||||||||||||
| 202 | {0x0B94, 0x0000, 0x0000, 0xB6}, | - | ||||||||||||
| 203 | {0x0B95, 0x0000, 0x0000, 0xB8}, | - | ||||||||||||
| 204 | {0x0B95, 0x0B82, 0x0000, 0xEC}, | - | ||||||||||||
| 205 | {0x0B95, 0x0BC1, 0x0000, 0xCC}, | - | ||||||||||||
| 206 | {0x0B95, 0x0BC2, 0x0000, 0xDC}, | - | ||||||||||||
| 207 | {0x0B99, 0x0000, 0x0000, 0xB9}, | - | ||||||||||||
| 208 | {0x0B99, 0x0B82, 0x0000, 0xED}, | - | ||||||||||||
| 209 | {0x0B99, 0x0BC1, 0x0000, 0x99}, | - | ||||||||||||
| 210 | {0x0B99, 0x0BC2, 0x0000, 0x9B}, | - | ||||||||||||
| 211 | {0x0B9A, 0x0000, 0x0000, 0xBA}, | - | ||||||||||||
| 212 | {0x0B9A, 0x0B82, 0x0000, 0xEE}, | - | ||||||||||||
| 213 | {0x0B9A, 0x0BC1, 0x0000, 0xCD}, | - | ||||||||||||
| 214 | {0x0B9A, 0x0BC2, 0x0000, 0xDD}, | - | ||||||||||||
| 215 | {0x0B9C, 0x0000, 0x0000, 0x83}, | - | ||||||||||||
| 216 | {0x0B9C, 0x0B82, 0x0000, 0x88}, | - | ||||||||||||
| 217 | {0x0B9E, 0x0000, 0x0000, 0xBB}, | - | ||||||||||||
| 218 | {0x0B9E, 0x0B82, 0x0000, 0xEF}, | - | ||||||||||||
| 219 | {0x0B9E, 0x0BC1, 0x0000, 0x9A}, | - | ||||||||||||
| 220 | {0x0B9E, 0x0BC2, 0x0000, 0x9C}, | - | ||||||||||||
| 221 | {0x0B9F, 0x0000, 0x0000, 0xBC}, | - | ||||||||||||
| 222 | {0x0B9F, 0x0B82, 0x0000, 0xF0}, | - | ||||||||||||
| 223 | {0x0B9F, 0x0BBF, 0x0000, 0xCA}, | - | ||||||||||||
| 224 | {0x0B9F, 0x0BC0, 0x0000, 0xCB}, | - | ||||||||||||
| 225 | {0x0B9F, 0x0BC1, 0x0000, 0xCE}, | - | ||||||||||||
| 226 | {0x0B9F, 0x0BC2, 0x0000, 0xDE}, | - | ||||||||||||
| 227 | {0x0BA1, 0x0B82, 0x0000, 0xF2}, | - | ||||||||||||
| 228 | {0x0BA3, 0x0000, 0x0000, 0xBD}, | - | ||||||||||||
| 229 | {0x0BA3, 0x0B82, 0x0000, 0xF1}, | - | ||||||||||||
| 230 | {0x0BA3, 0x0BC1, 0x0000, 0xCF}, | - | ||||||||||||
| 231 | {0x0BA3, 0x0BC2, 0x0000, 0xDF}, | - | ||||||||||||
| 232 | {0x0BA4, 0x0000, 0x0000, 0xBE}, | - | ||||||||||||
| 233 | {0x0BA4, 0x0BC1, 0x0000, 0xD0}, | - | ||||||||||||
| 234 | {0x0BA4, 0x0BC2, 0x0000, 0xE0}, | - | ||||||||||||
| 235 | {0x0BA8, 0x0000, 0x0000, 0xBF}, | - | ||||||||||||
| 236 | {0x0BA8, 0x0B82, 0x0000, 0xF3}, | - | ||||||||||||
| 237 | {0x0BA8, 0x0BC1, 0x0000, 0xD1}, | - | ||||||||||||
| 238 | {0x0BA8, 0x0BC2, 0x0000, 0xE1}, | - | ||||||||||||
| 239 | {0x0BA9, 0x0000, 0x0000, 0xC9}, | - | ||||||||||||
| 240 | {0x0BA9, 0x0B82, 0x0000, 0xFD}, | - | ||||||||||||
| 241 | {0x0BA9, 0x0BC1, 0x0000, 0xDB}, | - | ||||||||||||
| 242 | {0x0BA9, 0x0BC2, 0x0000, 0xEB}, | - | ||||||||||||
| 243 | {0x0BAA, 0x0000, 0x0000, 0xC0}, | - | ||||||||||||
| 244 | {0x0BAA, 0x0B82, 0x0000, 0xF4}, | - | ||||||||||||
| 245 | {0x0BAA, 0x0BC1, 0x0000, 0xD2}, | - | ||||||||||||
| 246 | {0x0BAA, 0x0BC2, 0x0000, 0xE2}, | - | ||||||||||||
| 247 | {0x0BAE, 0x0000, 0x0000, 0xC1}, | - | ||||||||||||
| 248 | {0x0BAE, 0x0B82, 0x0000, 0xF5}, | - | ||||||||||||
| 249 | {0x0BAE, 0x0BC1, 0x0000, 0xD3}, | - | ||||||||||||
| 250 | {0x0BAE, 0x0BC2, 0x0000, 0xE3}, | - | ||||||||||||
| 251 | {0x0BAF, 0x0000, 0x0000, 0xC2}, | - | ||||||||||||
| 252 | {0x0BAF, 0x0B82, 0x0000, 0xF6}, | - | ||||||||||||
| 253 | {0x0BAF, 0x0BC1, 0x0000, 0xD4}, | - | ||||||||||||
| 254 | {0x0BAF, 0x0BC2, 0x0000, 0xE4}, | - | ||||||||||||
| 255 | {0x0BB0, 0x0000, 0x0000, 0xC3}, | - | ||||||||||||
| 256 | {0x0BB0, 0x0B82, 0x0000, 0xF7}, | - | ||||||||||||
| 257 | {0x0BB0, 0x0BC1, 0x0000, 0xD5}, | - | ||||||||||||
| 258 | {0x0BB0, 0x0BC2, 0x0000, 0xE5}, | - | ||||||||||||
| 259 | {0x0BB1, 0x0000, 0x0000, 0xC8}, | - | ||||||||||||
| 260 | {0x0BB1, 0x0B82, 0x0000, 0xFC}, | - | ||||||||||||
| 261 | {0x0BB1, 0x0BC1, 0x0000, 0xDA}, | - | ||||||||||||
| 262 | {0x0BB1, 0x0BC2, 0x0000, 0xEA}, | - | ||||||||||||
| 263 | {0x0BB2, 0x0000, 0x0000, 0xC4}, | - | ||||||||||||
| 264 | {0x0BB2, 0x0B82, 0x0000, 0xF8}, | - | ||||||||||||
| 265 | {0x0BB2, 0x0BC1, 0x0000, 0xD6}, | - | ||||||||||||
| 266 | {0x0BB2, 0x0BC2, 0x0000, 0xE6}, | - | ||||||||||||
| 267 | {0x0BB3, 0x0000, 0x0000, 0xC7}, | - | ||||||||||||
| 268 | {0x0BB3, 0x0B82, 0x0000, 0xFB}, | - | ||||||||||||
| 269 | {0x0BB3, 0x0BC1, 0x0000, 0xD9}, | - | ||||||||||||
| 270 | {0x0BB3, 0x0BC2, 0x0000, 0xE9}, | - | ||||||||||||
| 271 | {0x0BB4, 0x0000, 0x0000, 0xC6}, | - | ||||||||||||
| 272 | {0x0BB4, 0x0B82, 0x0000, 0xFA}, | - | ||||||||||||
| 273 | {0x0BB4, 0x0BC1, 0x0000, 0xD8}, | - | ||||||||||||
| 274 | {0x0BB4, 0x0BC2, 0x0000, 0xE8}, | - | ||||||||||||
| 275 | {0x0BB5, 0x0000, 0x0000, 0xC5}, | - | ||||||||||||
| 276 | {0x0BB5, 0x0B82, 0x0000, 0xF9}, | - | ||||||||||||
| 277 | {0x0BB5, 0x0BC1, 0x0000, 0xD7}, | - | ||||||||||||
| 278 | {0x0BB5, 0x0BC2, 0x0000, 0xE7}, | - | ||||||||||||
| 279 | {0x0BB7, 0x0000, 0x0000, 0x84}, | - | ||||||||||||
| 280 | {0x0BB7, 0x0B82, 0x0000, 0x89}, | - | ||||||||||||
| 281 | {0x0BB8, 0x0000, 0x0000, 0x85}, | - | ||||||||||||
| 282 | {0x0BB8, 0x0B82, 0x0000, 0x8A}, | - | ||||||||||||
| 283 | {0x0BB9, 0x0000, 0x0000, 0x86}, | - | ||||||||||||
| 284 | {0x0BB9, 0x0B82, 0x0000, 0x8B}, | - | ||||||||||||
| 285 | {0x0BBE, 0x0000, 0x0000, 0xA1}, | - | ||||||||||||
| 286 | {0x0BBF, 0x0000, 0x0000, 0xA2}, | - | ||||||||||||
| 287 | {0x0BC0, 0x0000, 0x0000, 0xA3}, | - | ||||||||||||
| 288 | {0x0BC1, 0x0000, 0x0000, 0xA4}, | - | ||||||||||||
| 289 | {0x0BC2, 0x0000, 0x0000, 0xA5}, | - | ||||||||||||
| 290 | {0x0BC6, 0x0000, 0x0000, 0xA6}, | - | ||||||||||||
| 291 | {0x0BC7, 0x0000, 0x0000, 0xA7}, | - | ||||||||||||
| 292 | {0x0BC8, 0x0000, 0x0000, 0xA8}, | - | ||||||||||||
| 293 | {0x0BCC, 0x0000, 0x0000, 0xAA}, | - | ||||||||||||
| 294 | {0x0BE6, 0x0000, 0x0000, 0x80}, | - | ||||||||||||
| 295 | {0x0BE7, 0x0000, 0x0000, 0x81}, | - | ||||||||||||
| 296 | {0x0BE7, 0x0BB7, 0x0000, 0x87}, | - | ||||||||||||
| 297 | {0x0BE7, 0x0BB7, 0x0B82, 0x8C}, | - | ||||||||||||
| 298 | {0x0BE8, 0x0000, 0x0000, 0x8D}, | - | ||||||||||||
| 299 | {0x0BE9, 0x0000, 0x0000, 0x8E}, | - | ||||||||||||
| 300 | {0x0BEA, 0x0000, 0x0000, 0x8F}, | - | ||||||||||||
| 301 | {0x0BEB, 0x0000, 0x0000, 0x90}, | - | ||||||||||||
| 302 | {0x0BEC, 0x0000, 0x0000, 0x95}, | - | ||||||||||||
| 303 | {0x0BED, 0x0000, 0x0000, 0x96}, | - | ||||||||||||
| 304 | {0x0BEE, 0x0000, 0x0000, 0x97}, | - | ||||||||||||
| 305 | {0x0BEF, 0x0000, 0x0000, 0x98}, | - | ||||||||||||
| 306 | {0x0BF0, 0x0000, 0x0000, 0x9D}, | - | ||||||||||||
| 307 | {0x0BF1, 0x0000, 0x0000, 0x9E}, | - | ||||||||||||
| 308 | {0x0BF2, 0x0000, 0x0000, 0x9F}, | - | ||||||||||||
| 309 | {0x2018, 0x0000, 0x0000, 0x91}, | - | ||||||||||||
| 310 | {0x2019, 0x0000, 0x0000, 0x92}, | - | ||||||||||||
| 311 | {0x201C, 0x0000, 0x0000, 0x93}, | - | ||||||||||||
| 312 | {0x201C, 0x0000, 0x0000, 0x94} | - | ||||||||||||
| 313 | }; | - | ||||||||||||
| 314 | - | |||||||||||||
| 315 | static const ushort TsToUn [][3] = { | - | ||||||||||||
| 316 | // Starting at 0x80 | - | ||||||||||||
| 317 | {0x0BE6, 0x0000, 0x0000}, | - | ||||||||||||
| 318 | {0x0BE7, 0x0000, 0x0000}, | - | ||||||||||||
| 319 | {0x0000, 0x0000, 0x0000}, // unknown | - | ||||||||||||
| 320 | {0x0B9C, 0x0000, 0x0000}, | - | ||||||||||||
| 321 | {0x0BB7, 0x0000, 0x0000}, | - | ||||||||||||
| 322 | {0x0BB8, 0x0000, 0x0000}, | - | ||||||||||||
| 323 | {0x0BB9, 0x0000, 0x0000}, | - | ||||||||||||
| 324 | {0x0BE7, 0x0BB7, 0x0000}, | - | ||||||||||||
| 325 | {0x0B9C, 0x0B82, 0x0000}, | - | ||||||||||||
| 326 | {0x0BB7, 0x0B82, 0x0000}, | - | ||||||||||||
| 327 | {0x0BB8, 0x0B82, 0x0000}, | - | ||||||||||||
| 328 | {0x0BB9, 0x0B82, 0x0000}, | - | ||||||||||||
| 329 | {0x0BE7, 0x0BB7, 0x0B82}, | - | ||||||||||||
| 330 | {0x0BE8, 0x0000, 0x0000}, | - | ||||||||||||
| 331 | {0x0BE9, 0x0000, 0x0000}, | - | ||||||||||||
| 332 | {0x0BEA, 0x0000, 0x0000}, | - | ||||||||||||
| 333 | {0x0BEB, 0x0000, 0x0000}, | - | ||||||||||||
| 334 | {0x2018, 0x0000, 0x0000}, | - | ||||||||||||
| 335 | {0x2019, 0x0000, 0x0000}, | - | ||||||||||||
| 336 | {0x201C, 0x0000, 0x0000}, | - | ||||||||||||
| 337 | {0x201C, 0x0000, 0x0000}, // two of the same?? | - | ||||||||||||
| 338 | {0x0BEC, 0x0000, 0x0000}, | - | ||||||||||||
| 339 | {0x0BED, 0x0000, 0x0000}, | - | ||||||||||||
| 340 | {0x0BEE, 0x0000, 0x0000}, | - | ||||||||||||
| 341 | {0x0BEF, 0x0000, 0x0000}, | - | ||||||||||||
| 342 | {0x0B99, 0x0BC1, 0x0000}, | - | ||||||||||||
| 343 | {0x0B9E, 0x0BC1, 0x0000}, | - | ||||||||||||
| 344 | {0x0B99, 0x0BC2, 0x0000}, | - | ||||||||||||
| 345 | {0x0B9E, 0x0BC2, 0x0000}, | - | ||||||||||||
| 346 | {0x0BF0, 0x0000, 0x0000}, | - | ||||||||||||
| 347 | {0x0BF1, 0x0000, 0x0000}, | - | ||||||||||||
| 348 | {0x0BF2, 0x0000, 0x0000}, | - | ||||||||||||
| 349 | {0x00A0, 0x0000, 0x0000}, | - | ||||||||||||
| 350 | {0x0BBE, 0x0000, 0x0000}, | - | ||||||||||||
| 351 | {0x0BBF, 0x0000, 0x0000}, | - | ||||||||||||
| 352 | {0x0BC0, 0x0000, 0x0000}, | - | ||||||||||||
| 353 | {0x0BC1, 0x0000, 0x0000}, | - | ||||||||||||
| 354 | {0x0BC2, 0x0000, 0x0000}, | - | ||||||||||||
| 355 | {0x0BC6, 0x0000, 0x0000}, | - | ||||||||||||
| 356 | {0x0BC7, 0x0000, 0x0000}, | - | ||||||||||||
| 357 | {0x0BC8, 0x0000, 0x0000}, | - | ||||||||||||
| 358 | {0x00A9, 0x0000, 0x0000}, | - | ||||||||||||
| 359 | {0x0BCC, 0x0000, 0x0000}, | - | ||||||||||||
| 360 | {0x0B85, 0x0000, 0x0000}, | - | ||||||||||||
| 361 | {0x0B86, 0x0000, 0x0000}, | - | ||||||||||||
| 362 | {0x0B87, 0x0000, 0x0000}, | - | ||||||||||||
| 363 | {0x0B88, 0x0000, 0x0000}, | - | ||||||||||||
| 364 | {0x0B89, 0x0000, 0x0000}, | - | ||||||||||||
| 365 | {0x0B8A, 0x0000, 0x0000}, | - | ||||||||||||
| 366 | {0x0B8E, 0x0000, 0x0000}, | - | ||||||||||||
| 367 | {0x0B8F, 0x0000, 0x0000}, | - | ||||||||||||
| 368 | {0x0B90, 0x0000, 0x0000}, | - | ||||||||||||
| 369 | {0x0B92, 0x0000, 0x0000}, | - | ||||||||||||
| 370 | {0x0B93, 0x0000, 0x0000}, | - | ||||||||||||
| 371 | {0x0B94, 0x0000, 0x0000}, | - | ||||||||||||
| 372 | {0x0B83, 0x0000, 0x0000}, | - | ||||||||||||
| 373 | {0x0B95, 0x0000, 0x0000}, | - | ||||||||||||
| 374 | {0x0B99, 0x0000, 0x0000}, | - | ||||||||||||
| 375 | {0x0B9A, 0x0000, 0x0000}, | - | ||||||||||||
| 376 | {0x0B9E, 0x0000, 0x0000}, | - | ||||||||||||
| 377 | {0x0B9F, 0x0000, 0x0000}, | - | ||||||||||||
| 378 | {0x0BA3, 0x0000, 0x0000}, | - | ||||||||||||
| 379 | {0x0BA4, 0x0000, 0x0000}, | - | ||||||||||||
| 380 | {0x0BA8, 0x0000, 0x0000}, | - | ||||||||||||
| 381 | {0x0BAA, 0x0000, 0x0000}, | - | ||||||||||||
| 382 | {0x0BAE, 0x0000, 0x0000}, | - | ||||||||||||
| 383 | {0x0BAF, 0x0000, 0x0000}, | - | ||||||||||||
| 384 | {0x0BB0, 0x0000, 0x0000}, | - | ||||||||||||
| 385 | {0x0BB2, 0x0000, 0x0000}, | - | ||||||||||||
| 386 | {0x0BB5, 0x0000, 0x0000}, | - | ||||||||||||
| 387 | {0x0BB4, 0x0000, 0x0000}, | - | ||||||||||||
| 388 | {0x0BB3, 0x0000, 0x0000}, | - | ||||||||||||
| 389 | {0x0BB1, 0x0000, 0x0000}, | - | ||||||||||||
| 390 | {0x0BA9, 0x0000, 0x0000}, | - | ||||||||||||
| 391 | {0x0B9F, 0x0BBF, 0x0000}, | - | ||||||||||||
| 392 | {0x0B9F, 0x0BC0, 0x0000}, | - | ||||||||||||
| 393 | {0x0B95, 0x0BC1, 0x0000}, | - | ||||||||||||
| 394 | {0x0B9A, 0x0BC1, 0x0000}, | - | ||||||||||||
| 395 | {0x0B9F, 0x0BC1, 0x0000}, | - | ||||||||||||
| 396 | {0x0BA3, 0x0BC1, 0x0000}, | - | ||||||||||||
| 397 | {0x0BA4, 0x0BC1, 0x0000}, | - | ||||||||||||
| 398 | {0x0BA8, 0x0BC1, 0x0000}, | - | ||||||||||||
| 399 | {0x0BAA, 0x0BC1, 0x0000}, | - | ||||||||||||
| 400 | {0x0BAE, 0x0BC1, 0x0000}, | - | ||||||||||||
| 401 | {0x0BAF, 0x0BC1, 0x0000}, | - | ||||||||||||
| 402 | {0x0BB0, 0x0BC1, 0x0000}, | - | ||||||||||||
| 403 | {0x0BB2, 0x0BC1, 0x0000}, | - | ||||||||||||
| 404 | {0x0BB5, 0x0BC1, 0x0000}, | - | ||||||||||||
| 405 | {0x0BB4, 0x0BC1, 0x0000}, | - | ||||||||||||
| 406 | {0x0BB3, 0x0BC1, 0x0000}, | - | ||||||||||||
| 407 | {0x0BB1, 0x0BC1, 0x0000}, | - | ||||||||||||
| 408 | {0x0BA9, 0x0BC1, 0x0000}, | - | ||||||||||||
| 409 | {0x0B95, 0x0BC2, 0x0000}, | - | ||||||||||||
| 410 | {0x0B9A, 0x0BC2, 0x0000}, | - | ||||||||||||
| 411 | {0x0B9F, 0x0BC2, 0x0000}, | - | ||||||||||||
| 412 | {0x0BA3, 0x0BC2, 0x0000}, | - | ||||||||||||
| 413 | {0x0BA4, 0x0BC2, 0x0000}, | - | ||||||||||||
| 414 | {0x0BA8, 0x0BC2, 0x0000}, | - | ||||||||||||
| 415 | {0x0BAA, 0x0BC2, 0x0000}, | - | ||||||||||||
| 416 | {0x0BAE, 0x0BC2, 0x0000}, | - | ||||||||||||
| 417 | {0x0BAF, 0x0BC2, 0x0000}, | - | ||||||||||||
| 418 | {0x0BB0, 0x0BC2, 0x0000}, | - | ||||||||||||
| 419 | {0x0BB2, 0x0BC2, 0x0000}, | - | ||||||||||||
| 420 | {0x0BB5, 0x0BC2, 0x0000}, | - | ||||||||||||
| 421 | {0x0BB4, 0x0BC2, 0x0000}, | - | ||||||||||||
| 422 | {0x0BB3, 0x0BC2, 0x0000}, | - | ||||||||||||
| 423 | {0x0BB1, 0x0BC2, 0x0000}, | - | ||||||||||||
| 424 | {0x0BA9, 0x0BC2, 0x0000}, | - | ||||||||||||
| 425 | {0x0B95, 0x0B82, 0x0000}, | - | ||||||||||||
| 426 | {0x0B99, 0x0B82, 0x0000}, | - | ||||||||||||
| 427 | {0x0B9A, 0x0B82, 0x0000}, | - | ||||||||||||
| 428 | {0x0B9E, 0x0B82, 0x0000}, | - | ||||||||||||
| 429 | {0x0B9F, 0x0B82, 0x0000}, | - | ||||||||||||
| 430 | {0x0BA3, 0x0B82, 0x0000}, | - | ||||||||||||
| 431 | {0x0BA1, 0x0B82, 0x0000}, | - | ||||||||||||
| 432 | {0x0BA8, 0x0B82, 0x0000}, | - | ||||||||||||
| 433 | {0x0BAA, 0x0B82, 0x0000}, | - | ||||||||||||
| 434 | {0x0BAE, 0x0B82, 0x0000}, | - | ||||||||||||
| 435 | {0x0BAF, 0x0B82, 0x0000}, | - | ||||||||||||
| 436 | {0x0BB0, 0x0B82, 0x0000}, | - | ||||||||||||
| 437 | {0x0BB2, 0x0B82, 0x0000}, | - | ||||||||||||
| 438 | {0x0BB5, 0x0B82, 0x0000}, | - | ||||||||||||
| 439 | {0x0BB4, 0x0B82, 0x0000}, | - | ||||||||||||
| 440 | {0x0BB3, 0x0B82, 0x0000}, | - | ||||||||||||
| 441 | {0x0BB1, 0x0B82, 0x0000}, | - | ||||||||||||
| 442 | {0x0BA9, 0x0B82, 0x0000} | - | ||||||||||||
| 443 | }; | - | ||||||||||||
| 444 | - | |||||||||||||
| 445 | static int cmp(const ushort *s1, const ushort *s2, size_t len) | - | ||||||||||||
| 446 | { | - | ||||||||||||
| 447 | int diff = 0; | - | ||||||||||||
| 448 | - | |||||||||||||
| 449 | while (len-- && (diff = *s1++ - *s2++) == 0) 
 
 | 0 | ||||||||||||
| 450 | ; never executed:  ; | 0 | ||||||||||||
| 451 | - | |||||||||||||
| 452 | return diff; never executed:  return diff; | 0 | ||||||||||||
| 453 | } | - | ||||||||||||
| 454 | - | |||||||||||||
| 455 | static unsigned char qt_UnicodeToTSCII(ushort u1, ushort u2, ushort u3) | - | ||||||||||||
| 456 | { | - | ||||||||||||
| 457 | ushort s[3]; | - | ||||||||||||
| 458 | s[0] = u1; | - | ||||||||||||
| 459 | s[1] = u2; | - | ||||||||||||
| 460 | s[2] = u3; | - | ||||||||||||
| 461 | - | |||||||||||||
| 462 | int a = 0; // start pos | - | ||||||||||||
| 463 | int b = UnToTsLast; // end pos | - | ||||||||||||
| 464 | - | |||||||||||||
| 465 | // do a binary search for the composed unicode in the list | - | ||||||||||||
| 466 | while (a <= b) { 
 | 0 | ||||||||||||
| 467 | int w = (a + b) / 2; | - | ||||||||||||
| 468 | int j = cmp(UnToTs[w], s, 3); | - | ||||||||||||
| 469 | - | |||||||||||||
| 470 | if (j == 0) 
 | 0 | ||||||||||||
| 471 | // found it | - | ||||||||||||
| 472 | return UnToTs[w][3]; never executed:  return UnToTs[w][3]; | 0 | ||||||||||||
| 473 | - | |||||||||||||
| 474 | if (j < 0) 
 | 0 | ||||||||||||
| 475 | a = w + 1; never executed:  a = w + 1; | 0 | ||||||||||||
| 476 | else | - | ||||||||||||
| 477 | b = w - 1; never executed:  b = w - 1; | 0 | ||||||||||||
| 478 | } | - | ||||||||||||
| 479 | - | |||||||||||||
| 480 | return 0; never executed:  return 0; | 0 | ||||||||||||
| 481 | } | - | ||||||||||||
| 482 | - | |||||||||||||
| 483 | static unsigned int qt_TSCIIToUnicode(uint code, uint *s) | - | ||||||||||||
| 484 | { | - | ||||||||||||
| 485 | int len = 0; | - | ||||||||||||
| 486 | for (int i = 0; i < 3; i++) { 
 | 0 | ||||||||||||
| 487 | uint u = TsToUn[code & 0x7f][i]; | - | ||||||||||||
| 488 | s[i] = u; | - | ||||||||||||
| 489 | if (s[i]) len = i + 1; never executed:  len = i + 1;
 | 0 | ||||||||||||
| 490 | } never executed:  end of block | 0 | ||||||||||||
| 491 | - | |||||||||||||
| 492 | return len; never executed:  return len; | 0 | ||||||||||||
| 493 | } | - | ||||||||||||
| 494 | - | |||||||||||||
| 495 | QT_END_NAMESPACE | - | ||||||||||||
| 496 | - | |||||||||||||
| 497 | #endif // QT_NO_CODECS | - | ||||||||||||
| Source code | Switch to Preprocessed file |