| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com> | 3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com> |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 else if (!strcasecmp(standardName, "iso-8859-9")) | 106 else if (!strcasecmp(standardName, "iso-8859-9")) |
| 107 // This name is returned in different case by ICU 3.2 and 3.6. | 107 // This name is returned in different case by ICU 3.2 and 3.6. |
| 108 standardName = "windows-1254"; | 108 standardName = "windows-1254"; |
| 109 else if (!strcmp(standardName, "TIS-620")) | 109 else if (!strcmp(standardName, "TIS-620")) |
| 110 standardName = "windows-874"; | 110 standardName = "windows-874"; |
| 111 #endif | 111 #endif |
| 112 | 112 |
| 113 registrar(standardName, standardName); | 113 registrar(standardName, standardName); |
| 114 | 114 |
| 115 uint16_t numAliases = ucnv_countAliases(name, &error); | 115 uint16_t numAliases = ucnv_countAliases(name, &error); |
| 116 ASSERT(U_SUCCESS(error)); | 116 DCHECK(U_SUCCESS(error)); |
| 117 if (U_SUCCESS(error)) | 117 if (U_SUCCESS(error)) |
| 118 for (uint16_t j = 0; j < numAliases; ++j) { | 118 for (uint16_t j = 0; j < numAliases; ++j) { |
| 119 error = U_ZERO_ERROR; | 119 error = U_ZERO_ERROR; |
| 120 const char* alias = ucnv_getAlias(name, j, &error); | 120 const char* alias = ucnv_getAlias(name, j, &error); |
| 121 ASSERT(U_SUCCESS(error)); | 121 DCHECK(U_SUCCESS(error)); |
| 122 if (U_SUCCESS(error) && alias != standardName) | 122 if (U_SUCCESS(error) && alias != standardName) |
| 123 registrar(alias, standardName); | 123 registrar(alias, standardName); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 // These two entries have to be added here because ICU's converter table | 127 // These two entries have to be added here because ICU's converter table |
| 128 // cannot have both ISO-8859-8-I and ISO-8859-8. | 128 // cannot have both ISO-8859-8-I and ISO-8859-8. |
| 129 registrar("csISO88598I", "ISO-8859-8-I"); | 129 registrar("csISO88598I", "ISO-8859-8-I"); |
| 130 registrar("logical", "ISO-8859-8-I"); | 130 registrar("logical", "ISO-8859-8-I"); |
| 131 | 131 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 if (m_converterICU) { | 262 if (m_converterICU) { |
| 263 UConverter*& cachedConverter = cachedConverterICU(); | 263 UConverter*& cachedConverter = cachedConverterICU(); |
| 264 if (cachedConverter) | 264 if (cachedConverter) |
| 265 ucnv_close(cachedConverter); | 265 ucnv_close(cachedConverter); |
| 266 cachedConverter = m_converterICU; | 266 cachedConverter = m_converterICU; |
| 267 m_converterICU = 0; | 267 m_converterICU = 0; |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 | 270 |
| 271 void TextCodecICU::createICUConverter() const { | 271 void TextCodecICU::createICUConverter() const { |
| 272 ASSERT(!m_converterICU); | 272 DCHECK(!m_converterICU); |
| 273 | 273 |
| 274 #if defined(USING_SYSTEM_ICU) | 274 #if defined(USING_SYSTEM_ICU) |
| 275 const char* name = m_encoding.name(); | 275 const char* name = m_encoding.name(); |
| 276 m_needsGBKFallbacks = | 276 m_needsGBKFallbacks = |
| 277 name[0] == 'G' && name[1] == 'B' && name[2] == 'K' && !name[3]; | 277 name[0] == 'G' && name[1] == 'B' && name[2] == 'K' && !name[3]; |
| 278 #endif | 278 #endif |
| 279 | 279 |
| 280 UErrorCode err; | 280 UErrorCode err; |
| 281 | 281 |
| 282 UConverter*& cachedConverter = cachedConverterICU(); | 282 UConverter*& cachedConverter = cachedConverterICU(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 }; | 346 }; |
| 347 | 347 |
| 348 String TextCodecICU::decode(const char* bytes, | 348 String TextCodecICU::decode(const char* bytes, |
| 349 size_t length, | 349 size_t length, |
| 350 FlushBehavior flush, | 350 FlushBehavior flush, |
| 351 bool stopOnError, | 351 bool stopOnError, |
| 352 bool& sawError) { | 352 bool& sawError) { |
| 353 // Get a converter for the passed-in encoding. | 353 // Get a converter for the passed-in encoding. |
| 354 if (!m_converterICU) { | 354 if (!m_converterICU) { |
| 355 createICUConverter(); | 355 createICUConverter(); |
| 356 ASSERT(m_converterICU); | 356 DCHECK(m_converterICU); |
| 357 if (!m_converterICU) { | 357 if (!m_converterICU) { |
| 358 DLOG(ERROR) | 358 DLOG(ERROR) |
| 359 << "error creating ICU encoder even though encoding was in table"; | 359 << "error creating ICU encoder even though encoding was in table"; |
| 360 return String(); | 360 return String(); |
| 361 } | 361 } |
| 362 } | 362 } |
| 363 | 363 |
| 364 ErrorCallbackSetter callbackSetter(m_converterICU, stopOnError); | 364 ErrorCallbackSetter callbackSetter(m_converterICU, stopOnError); |
| 365 | 365 |
| 366 StringBuilder result; | 366 StringBuilder result; |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 &err); | 651 &err); |
| 652 #else | 652 #else |
| 653 ucnv_setFromUCallBack(m_converterICU, | 653 ucnv_setFromUCallBack(m_converterICU, |
| 654 m_needsGBKFallbacks ? gbkCssEscapedEntityCallack | 654 m_needsGBKFallbacks ? gbkCssEscapedEntityCallack |
| 655 : cssEscapedEntityCallback, | 655 : cssEscapedEntityCallback, |
| 656 0, 0, 0, &err); | 656 0, 0, 0, &err); |
| 657 #endif | 657 #endif |
| 658 break; | 658 break; |
| 659 } | 659 } |
| 660 | 660 |
| 661 ASSERT(U_SUCCESS(err)); | 661 DCHECK(U_SUCCESS(err)); |
| 662 if (U_FAILURE(err)) | 662 if (U_FAILURE(err)) |
| 663 return CString(); | 663 return CString(); |
| 664 | 664 |
| 665 Vector<char> result; | 665 Vector<char> result; |
| 666 size_t size = 0; | 666 size_t size = 0; |
| 667 do { | 667 do { |
| 668 char buffer[ConversionBufferSize]; | 668 char buffer[ConversionBufferSize]; |
| 669 char* target = buffer; | 669 char* target = buffer; |
| 670 char* targetLimit = target + ConversionBufferSize; | 670 char* targetLimit = target + ConversionBufferSize; |
| 671 err = U_ZERO_ERROR; | 671 err = U_ZERO_ERROR; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 702 return encodeCommon(characters, length, handling); | 702 return encodeCommon(characters, length, handling); |
| 703 } | 703 } |
| 704 | 704 |
| 705 CString TextCodecICU::encode(const LChar* characters, | 705 CString TextCodecICU::encode(const LChar* characters, |
| 706 size_t length, | 706 size_t length, |
| 707 UnencodableHandling handling) { | 707 UnencodableHandling handling) { |
| 708 return encodeCommon(characters, length, handling); | 708 return encodeCommon(characters, length, handling); |
| 709 } | 709 } |
| 710 | 710 |
| 711 } // namespace WTF | 711 } // namespace WTF |
| OLD | NEW |