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

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

Issue 1366433005: Remove dedicated TextCodecUTF16 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 2 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
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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 registrar("iso_8859-9", "windows-1254"); 213 registrar("iso_8859-9", "windows-1254");
214 registrar("iso_8859-15", "ISO-8859-15"); 214 registrar("iso_8859-15", "ISO-8859-15");
215 registrar("koi8_r", "KOI8-R"); 215 registrar("koi8_r", "KOI8-R");
216 registrar("x-cp1253", "windows-1253"); 216 registrar("x-cp1253", "windows-1253");
217 registrar("x-cp1254", "windows-1254"); 217 registrar("x-cp1254", "windows-1254");
218 registrar("x-cp1255", "windows-1255"); 218 registrar("x-cp1255", "windows-1255");
219 registrar("x-cp1256", "windows-1256"); 219 registrar("x-cp1256", "windows-1256");
220 registrar("x-cp1257", "windows-1257"); 220 registrar("x-cp1257", "windows-1257");
221 registrar("x-cp1258", "windows-1258"); 221 registrar("x-cp1258", "windows-1258");
222 #endif 222 #endif
223
224 // TODO(jshin): Move to ICU's data/mappings/convrtrs.txt aliases.
225 registrar("UTF-16", "utf-16le");
226 registrar("ISO-10646-UCS-2", "utf-16le");
227 registrar("UCS-2", "utf-16le");
228 registrar("Unicode", "utf-16le");
229 registrar("csUnicode", "utf-16le");
230 registrar("unicodeFEFF", "utf-16le");
231 registrar("unicodeFFFE", "utf-16be");
223 } 232 }
224 233
225 void TextCodecICU::registerCodecs(TextCodecRegistrar registrar) 234 void TextCodecICU::registerCodecs(TextCodecRegistrar registrar)
226 { 235 {
227 // See comment above in registerEncodingNames. 236 // See comment above in registerEncodingNames.
228 registrar("ISO-8859-8-I", create, 0); 237 registrar("ISO-8859-8-I", create, 0);
229 238
230 int32_t numEncodings = ucnv_countAvailable(); 239 int32_t numEncodings = ucnv_countAvailable();
231 for (int32_t i = 0; i < numEncodings; ++i) { 240 for (int32_t i = 0; i < numEncodings; ++i) {
232 const char* name = ucnv_getAvailableName(i); 241 const char* name = ucnv_getAvailableName(i);
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 546
538 CString TextCodecICU::encodeInternal(const TextCodecInput& input, UnencodableHan dling handling) 547 CString TextCodecICU::encodeInternal(const TextCodecInput& input, UnencodableHan dling handling)
539 { 548 {
540 const UChar* source = input.begin(); 549 const UChar* source = input.begin();
541 const UChar* end = input.end(); 550 const UChar* end = input.end();
542 551
543 UErrorCode err = U_ZERO_ERROR; 552 UErrorCode err = U_ZERO_ERROR;
544 553
545 switch (handling) { 554 switch (handling) {
546 case QuestionMarksForUnencodables: 555 case QuestionMarksForUnencodables:
547 ucnv_setSubstChars(m_converterICU, "?", 1, &err); 556 if (!m_encoding.isNonByteBasedEncoding())
557 ucnv_setSubstChars(m_converterICU, "?", 1, &err);
548 #if !defined(USING_SYSTEM_ICU) 558 #if !defined(USING_SYSTEM_ICU)
549 ucnv_setFromUCallBack(m_converterICU, UCNV_FROM_U_CALLBACK_SUBSTITUTE, 0 , 0, 0, &err); 559 ucnv_setFromUCallBack(m_converterICU, UCNV_FROM_U_CALLBACK_SUBSTITUTE, 0 , 0, 0, &err);
550 #else 560 #else
551 ucnv_setFromUCallBack(m_converterICU, m_needsGBKFallbacks ? gbkCallbackS ubstitute : UCNV_FROM_U_CALLBACK_SUBSTITUTE, 0, 0, 0, &err); 561 ucnv_setFromUCallBack(m_converterICU, m_needsGBKFallbacks ? gbkCallbackS ubstitute : UCNV_FROM_U_CALLBACK_SUBSTITUTE, 0, 0, 0, &err);
552 #endif 562 #endif
553 break; 563 break;
554 case EntitiesForUnencodables: 564 case EntitiesForUnencodables:
555 #if !defined(USING_SYSTEM_ICU) 565 #if !defined(USING_SYSTEM_ICU)
556 ucnv_setFromUCallBack(m_converterICU, numericEntityCallback, 0, 0, 0, &e rr); 566 ucnv_setFromUCallBack(m_converterICU, numericEntityCallback, 0, 0, 0, &e rr);
557 #else 567 #else
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 { 624 {
615 return encodeCommon(characters, length, handling); 625 return encodeCommon(characters, length, handling);
616 } 626 }
617 627
618 CString TextCodecICU::encode(const LChar* characters, size_t length, Unencodable Handling handling) 628 CString TextCodecICU::encode(const LChar* characters, size_t length, Unencodable Handling handling)
619 { 629 {
620 return encodeCommon(characters, length, handling); 630 return encodeCommon(characters, length, handling);
621 } 631 }
622 632
623 } // namespace WTF 633 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/BUILD.gn ('k') | third_party/WebKit/Source/wtf/text/TextCodecUTF16.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698