| 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 const char* cachedName = ucnv_getName(cachedConverter, &err); | 282 const char* cachedName = ucnv_getName(cachedConverter, &err); |
| 283 if (U_SUCCESS(err) && m_encoding == cachedName) { | 283 if (U_SUCCESS(err) && m_encoding == cachedName) { |
| 284 m_converterICU = cachedConverter; | 284 m_converterICU = cachedConverter; |
| 285 cachedConverter = 0; | 285 cachedConverter = 0; |
| 286 return; | 286 return; |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 | 289 |
| 290 err = U_ZERO_ERROR; | 290 err = U_ZERO_ERROR; |
| 291 m_converterICU = ucnv_open(m_encoding.name(), &err); | 291 m_converterICU = ucnv_open(m_encoding.name(), &err); |
| 292 #if !LOG_DISABLED | 292 DLOG_IF(ERROR, err == U_AMBIGUOUS_ALIAS_WARNING) << "ICU ambiguous alias war
ning for encoding: " << m_encoding.name(); |
| 293 if (err == U_AMBIGUOUS_ALIAS_WARNING) | |
| 294 WTF_LOG_ERROR("ICU ambiguous alias warning for encoding: %s", m_encoding
.name()); | |
| 295 #endif | |
| 296 if (m_converterICU) | 293 if (m_converterICU) |
| 297 ucnv_setFallback(m_converterICU, TRUE); | 294 ucnv_setFallback(m_converterICU, TRUE); |
| 298 } | 295 } |
| 299 | 296 |
| 300 int TextCodecICU::decodeToBuffer(UChar* target, UChar* targetLimit, const char*&
source, const char* sourceLimit, int32_t* offsets, bool flush, UErrorCode& err) | 297 int TextCodecICU::decodeToBuffer(UChar* target, UChar* targetLimit, const char*&
source, const char* sourceLimit, int32_t* offsets, bool flush, UErrorCode& err) |
| 301 { | 298 { |
| 302 UChar* targetStart = target; | 299 UChar* targetStart = target; |
| 303 err = U_ZERO_ERROR; | 300 err = U_ZERO_ERROR; |
| 304 ucnv_toUnicode(m_converterICU, &target, targetLimit, &source, sourceLimit, o
ffsets, flush, &err); | 301 ucnv_toUnicode(m_converterICU, &target, targetLimit, &source, sourceLimit, o
ffsets, flush, &err); |
| 305 return target - targetStart; | 302 return target - targetStart; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 UConverterToUCallback m_savedAction; | 337 UConverterToUCallback m_savedAction; |
| 341 }; | 338 }; |
| 342 | 339 |
| 343 String TextCodecICU::decode(const char* bytes, size_t length, FlushBehavior flus
h, bool stopOnError, bool& sawError) | 340 String TextCodecICU::decode(const char* bytes, size_t length, FlushBehavior flus
h, bool stopOnError, bool& sawError) |
| 344 { | 341 { |
| 345 // Get a converter for the passed-in encoding. | 342 // Get a converter for the passed-in encoding. |
| 346 if (!m_converterICU) { | 343 if (!m_converterICU) { |
| 347 createICUConverter(); | 344 createICUConverter(); |
| 348 ASSERT(m_converterICU); | 345 ASSERT(m_converterICU); |
| 349 if (!m_converterICU) { | 346 if (!m_converterICU) { |
| 350 WTF_LOG_ERROR("error creating ICU encoder even though encoding was i
n table"); | 347 DLOG(ERROR) << "error creating ICU encoder even though encoding was
in table"; |
| 351 return String(); | 348 return String(); |
| 352 } | 349 } |
| 353 } | 350 } |
| 354 | 351 |
| 355 ErrorCallbackSetter callbackSetter(m_converterICU, stopOnError); | 352 ErrorCallbackSetter callbackSetter(m_converterICU, stopOnError); |
| 356 | 353 |
| 357 StringBuilder result; | 354 StringBuilder result; |
| 358 | 355 |
| 359 UChar buffer[ConversionBufferSize]; | 356 UChar buffer[ConversionBufferSize]; |
| 360 UChar* bufferLimit = buffer + ConversionBufferSize; | 357 UChar* bufferLimit = buffer + ConversionBufferSize; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 { | 569 { |
| 573 return encodeCommon(characters, length, handling); | 570 return encodeCommon(characters, length, handling); |
| 574 } | 571 } |
| 575 | 572 |
| 576 CString TextCodecICU::encode(const LChar* characters, size_t length, Unencodable
Handling handling) | 573 CString TextCodecICU::encode(const LChar* characters, size_t length, Unencodable
Handling handling) |
| 577 { | 574 { |
| 578 return encodeCommon(characters, length, handling); | 575 return encodeCommon(characters, length, handling); |
| 579 } | 576 } |
| 580 | 577 |
| 581 } // namespace WTF | 578 } // namespace WTF |
| OLD | NEW |