Changeset 846 for trunk/src/plugins/codecs/cn/qgb18030codec.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
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/plugins/codecs/cn/qgb18030codec.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]) … … 61 61 #define Is4thByte(c) (InRange((c), 0x30, 0x39)) 62 62 63 #define QValidChar(u) ((u) ? QChar((ushort)(u)) : QChar(QChar::ReplacementCharacter))63 #define (QChar::ReplacementCharacter)) 64 64 65 65 /* User-defined areas: UDA 1: 0xAAA1 - 0xAFFE (564/0) … … 161 161 uchar buf[4]; 162 162 int nbuf = 0; 163 QCharreplacement = QChar::ReplacementCharacter;163 replacement = QChar::ReplacementCharacter; 164 164 if (state) { 165 165 if (state->flags & ConvertInvalidToNull) … … 174 174 175 175 QString result; 176 177 178 176 179 //qDebug("QGb18030Decoder::toUnicode(const char* chars, int len = %d)", len); 177 180 for (int i = 0; i < len; i++) { … … 181 184 if (ch < 0x80) { 182 185 // ASCII 183 result += QLatin1Char(ch); 186 resultData[unicodeLen] = ch; 187 ++unicodeLen; 184 188 } else if (Is1stByte(ch)) { 185 189 // GB18030? … … 188 192 } else { 189 193 // Invalid 190 result += replacement; 194 resultData[unicodeLen] = replacement; 195 ++unicodeLen; 191 196 ++invalid; 192 197 } … … 199 204 uint u = qt_Gb18030ToUnicode(buf, clen); 200 205 if (clen == 2) { 201 result += QValidChar(u); 206 resultData[unicodeLen] = qValidChar(static_cast<ushort>(u)); 207 ++unicodeLen; 202 208 } else { 203 result += replacement; 209 resultData[unicodeLen] = replacement; 210 ++unicodeLen; 204 211 ++invalid; 205 212 } … … 210 217 } else { 211 218 // Error 212 result += replacement; 219 resultData[unicodeLen] = replacement; 220 ++unicodeLen; 213 221 ++invalid; 214 222 nbuf = 0; … … 221 229 nbuf = 3; 222 230 } else { 223 result += replacement; 231 resultData[unicodeLen] = replacement; 232 ++unicodeLen; 224 233 ++invalid; 225 234 nbuf = 0; … … 233 242 uint u = qt_Gb18030ToUnicode(buf, clen); 234 243 if (clen == 4) { 235 result += QValidChar(u); 244 resultData[unicodeLen] = qValidChar(u); 245 ++unicodeLen; 236 246 } else { 237 result += replacement; 247 resultData[unicodeLen] = replacement; 248 ++unicodeLen; 238 249 ++invalid; 239 250 } 240 251 } else { 241 result += replacement; 252 resultData[unicodeLen] = replacement; 253 ++unicodeLen; 242 254 ++invalid; 243 255 } … … 246 258 } 247 259 } 260 261 248 262 if (state) { 249 263 state->remainingChars = nbuf; … … 306 320 uchar buf[2]; 307 321 int nbuf = 0; 308 QCharreplacement = QChar::ReplacementCharacter;322 replacement = QChar::ReplacementCharacter; 309 323 if (state) { 310 324 if (state->flags & ConvertInvalidToNull) … … 317 331 318 332 QString result; 333 334 335 319 336 320 337 //qDebug("QGbkDecoder::toUnicode(const char* chars = \"%s\", int len = %d)", chars, len); … … 325 342 if (ch < 0x80) { 326 343 // ASCII 327 result += QLatin1Char(ch); 344 resultData[unicodeLen] = ch; 345 ++unicodeLen; 328 346 } else if (Is1stByte(ch)) { 329 347 // GBK 1st byte? … … 332 350 } else { 333 351 // Invalid 334 result += replacement; 352 resultData[unicodeLen] = replacement; 353 ++unicodeLen; 335 354 ++invalid; 336 355 } … … 343 362 uint u = qt_Gb18030ToUnicode(buf, clen); 344 363 if (clen == 2) { 345 result += QValidChar(u); 364 resultData[unicodeLen] = qValidChar(static_cast<ushort>(u)); 365 ++unicodeLen; 346 366 } else { 347 result += replacement; 367 resultData[unicodeLen] = replacement; 368 ++unicodeLen; 348 369 ++invalid; 349 370 } … … 351 372 } else { 352 373 // Error 353 result += replacement; 374 resultData[unicodeLen] = replacement; 375 ++unicodeLen; 354 376 ++invalid; 355 377 nbuf = 0; … … 358 380 } 359 381 } 382 360 383 361 384 if (state) { … … 446 469 uchar buf[2]; 447 470 int nbuf = 0; 448 QCharreplacement = QChar::ReplacementCharacter;471 replacement = QChar::ReplacementCharacter; 449 472 if (state) { 450 473 if (state->flags & ConvertInvalidToNull) … … 457 480 458 481 QString result; 482 483 484 459 485 //qDebug("QGb2312Decoder::toUnicode(const char* chars, int len = %d)", len); 460 486 for (int i=0; i<len; i++) { … … 464 490 if (ch < 0x80) { 465 491 // ASCII 466 result += QLatin1Char(ch); 492 resultData[unicodeLen] = ch; 493 ++unicodeLen; 467 494 } else if (IsByteInGb2312(ch)) { 468 495 // GB2312 1st byte? … … 471 498 } else { 472 499 // Invalid 473 result += replacement; 500 resultData[unicodeLen] = replacement; 501 ++unicodeLen; 474 502 ++invalid; 475 503 } … … 482 510 uint u = qt_Gb18030ToUnicode(buf, clen); 483 511 if (clen == 2) { 484 result += QValidChar(u); 512 resultData[unicodeLen] = qValidChar(static_cast<ushort>(u)); 513 ++unicodeLen; 485 514 } else { 486 result += replacement; 515 resultData[unicodeLen] = replacement; 516 ++unicodeLen; 487 517 ++invalid; 488 518 } … … 490 520 } else { 491 521 // Error 492 result += replacement; 522 resultData[unicodeLen] = replacement; 523 ++unicodeLen; 493 524 ++invalid; 494 525 nbuf = 0; … … 497 528 } 498 529 } 530 499 531 500 532 if (state) {
Note:
See TracChangeset
for help on using the changeset viewer.