Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(669)

Side by Side Diff: Source/wtf/text/TextCodecICU.cpp

Issue 999953003: Remove dedicated TextCodecUTF16 (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/encoding/TextEncoder.cpp ('k') | Source/wtf/text/TextCodecUTF16.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 registrar("iso_8859-8", "ISO-8859-8"); 205 registrar("iso_8859-8", "ISO-8859-8");
206 registrar("iso_8859-9", "windows-1254"); 206 registrar("iso_8859-9", "windows-1254");
207 registrar("iso_8859-15", "ISO-8859-15"); 207 registrar("iso_8859-15", "ISO-8859-15");
208 registrar("koi8_r", "KOI8-R"); 208 registrar("koi8_r", "KOI8-R");
209 registrar("x-cp1253", "windows-1253"); 209 registrar("x-cp1253", "windows-1253");
210 registrar("x-cp1254", "windows-1254"); 210 registrar("x-cp1254", "windows-1254");
211 registrar("x-cp1255", "windows-1255"); 211 registrar("x-cp1255", "windows-1255");
212 registrar("x-cp1256", "windows-1256"); 212 registrar("x-cp1256", "windows-1256");
213 registrar("x-cp1257", "windows-1257"); 213 registrar("x-cp1257", "windows-1257");
214 registrar("x-cp1258", "windows-1258"); 214 registrar("x-cp1258", "windows-1258");
215
216 // Standard labels for UTF-16.
217 registrar("UTF-16", "utf-16le");
218 // Non-standard labels for UTF-16.
219 registrar("ISO-10646-UCS-2", "utf-16le");
220 registrar("UCS-2", "utf-16le");
221 registrar("Unicode", "utf-16le");
222 registrar("csUnicode", "utf-16le");
223 registrar("unicodeFEFF", "utf-16le");
224 registrar("unicodeFFFE", "utf-16be");
215 } 225 }
216 226
217 void TextCodecICU::registerCodecs(TextCodecRegistrar registrar) 227 void TextCodecICU::registerCodecs(TextCodecRegistrar registrar)
218 { 228 {
219 // See comment above in registerEncodingNames. 229 // See comment above in registerEncodingNames.
220 registrar("ISO-8859-8-I", create, 0); 230 registrar("ISO-8859-8-I", create, 0);
221 231
222 int32_t numEncodings = ucnv_countAvailable(); 232 int32_t numEncodings = ucnv_countAvailable();
223 for (int32_t i = 0; i < numEncodings; ++i) { 233 for (int32_t i = 0; i < numEncodings; ++i) {
224 const char* name = ucnv_getAvailableName(i); 234 const char* name = ucnv_getAvailableName(i);
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 490
481 CString TextCodecICU::encodeInternal(const TextCodecInput& input, UnencodableHan dling handling) 491 CString TextCodecICU::encodeInternal(const TextCodecInput& input, UnencodableHan dling handling)
482 { 492 {
483 const UChar* source = input.begin(); 493 const UChar* source = input.begin();
484 const UChar* end = input.end(); 494 const UChar* end = input.end();
485 495
486 UErrorCode err = U_ZERO_ERROR; 496 UErrorCode err = U_ZERO_ERROR;
487 497
488 switch (handling) { 498 switch (handling) {
489 case QuestionMarksForUnencodables: 499 case QuestionMarksForUnencodables:
490 ucnv_setSubstChars(m_converterICU, "?", 1, &err); 500 if (!m_encoding.isNonByteBasedEncoding())
501 ucnv_setSubstChars(m_converterICU, "?", 1, &err);
491 ucnv_setFromUCallBack(m_converterICU, m_needsGBKFallbacks ? gbkCallb ackSubstitute : UCNV_FROM_U_CALLBACK_SUBSTITUTE, 0, 0, 0, &err); 502 ucnv_setFromUCallBack(m_converterICU, m_needsGBKFallbacks ? gbkCallb ackSubstitute : UCNV_FROM_U_CALLBACK_SUBSTITUTE, 0, 0, 0, &err);
492 break; 503 break;
493 case EntitiesForUnencodables: 504 case EntitiesForUnencodables:
494 ucnv_setFromUCallBack(m_converterICU, m_needsGBKFallbacks ? gbkCallb ackEscape : UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_DEC, 0, 0, &err); 505 ucnv_setFromUCallBack(m_converterICU, m_needsGBKFallbacks ? gbkCallb ackEscape : UCNV_FROM_U_CALLBACK_ESCAPE, UCNV_ESCAPE_XML_DEC, 0, 0, &err);
495 break; 506 break;
496 case URLEncodedEntitiesForUnencodables: 507 case URLEncodedEntitiesForUnencodables:
497 ucnv_setFromUCallBack(m_converterICU, m_needsGBKFallbacks ? gbkUrlEs capedEntityCallack : urlEscapedEntityCallback, 0, 0, 0, &err); 508 ucnv_setFromUCallBack(m_converterICU, m_needsGBKFallbacks ? gbkUrlEs capedEntityCallack : urlEscapedEntityCallback, 0, 0, 0, &err);
498 break; 509 break;
499 } 510 }
500 511
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 { 549 {
539 return encodeCommon(characters, length, handling); 550 return encodeCommon(characters, length, handling);
540 } 551 }
541 552
542 CString TextCodecICU::encode(const LChar* characters, size_t length, Unencodable Handling handling) 553 CString TextCodecICU::encode(const LChar* characters, size_t length, Unencodable Handling handling)
543 { 554 {
544 return encodeCommon(characters, length, handling); 555 return encodeCommon(characters, length, handling);
545 } 556 }
546 557
547 } // namespace WTF 558 } // namespace WTF
OLDNEW
« no previous file with comments | « Source/modules/encoding/TextEncoder.cpp ('k') | Source/wtf/text/TextCodecUTF16.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698