void TextCodecICU::createICUConverter() const { ASSERT(!m_converterICU); #if defined(USING_SYSTEM_ICU) const char* name = m_encoding.name(); m_needsGBKFallbacks = name[0] == 'G' && name[1] == 'B' && name[2] == 'K' && !name[3]; #endif UErrorCode err; UConverter*& cachedConverter = cachedConverterICU(); if (cachedConverter) { err = U_ZERO_ERROR; const char* cachedName = ucnv_getName(cachedConverter, &err); if (U_SUCCESS(err) && m_encoding == cachedName) { m_converterICU = cachedConverter; cachedConverter = 0; return; } } err = U_ZERO_ERROR; m_converterICU = ucnv_open(m_encoding.name(), &err); #if !LOG_DISABLED if (err == U_AMBIGUOUS_ALIAS_WARNING) WTF_LOG_ERROR("ICU ambiguous alias warning for encoding: %s", m_encoding.name()); #endif if (m_converterICU) ucnv_setFallback(m_converterICU, TRUE); }
void TextCodecICU::createICUConverter() const { ASSERT(!m_converterICU); UErrorCode err; m_needsGBKFallbacks = !strcmp(m_encodingName, "GBK"); UConverter*& cachedConverter = cachedConverterICU(); if (cachedConverter) { err = U_ZERO_ERROR; const char* cachedConverterName = ucnv_getName(cachedConverter, &err); if (U_SUCCESS(err) && !strcmp(m_canonicalConverterName, cachedConverterName)) { m_converterICU = cachedConverter; cachedConverter = 0; return; } } err = U_ZERO_ERROR; m_converterICU = ucnv_open(m_canonicalConverterName, &err); ASSERT(U_SUCCESS(err)); if (m_converterICU) ucnv_setFallback(m_converterICU, TRUE); }
void TextCodecICU::releaseICUConverter() const { if (m_converterICU) { UConverter*& cachedConverter = cachedConverterICU(); if (cachedConverter) ucnv_close(cachedConverter); cachedConverter = m_converterICU; m_converterICU = 0; } }