| 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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 | 601 |
| 602 CString TextCodecICU::encodeInternal(const TextCodecInput& input, | 602 CString TextCodecICU::encodeInternal(const TextCodecInput& input, |
| 603 UnencodableHandling handling) { | 603 UnencodableHandling handling) { |
| 604 const UChar* source = input.begin(); | 604 const UChar* source = input.begin(); |
| 605 const UChar* end = input.end(); | 605 const UChar* end = input.end(); |
| 606 | 606 |
| 607 UErrorCode err = U_ZERO_ERROR; | 607 UErrorCode err = U_ZERO_ERROR; |
| 608 | 608 |
| 609 switch (handling) { | 609 switch (handling) { |
| 610 case QuestionMarksForUnencodables: | 610 case QuestionMarksForUnencodables: |
| 611 ucnv_setSubstChars(m_converterICU, "?", 1, &err); | 611 // Non-byte-based encodings (i.e. UTF-16/32) don't need substitutions |
| 612 // since they can encode any code point, and ucnv_setSubstChars would |
| 613 // require a multi-byte substitution anyway. |
| 614 if (!m_encoding.isNonByteBasedEncoding()) |
| 615 ucnv_setSubstChars(m_converterICU, "?", 1, &err); |
| 612 #if !defined(USING_SYSTEM_ICU) | 616 #if !defined(USING_SYSTEM_ICU) |
| 613 ucnv_setFromUCallBack(m_converterICU, UCNV_FROM_U_CALLBACK_SUBSTITUTE, 0, | 617 ucnv_setFromUCallBack(m_converterICU, UCNV_FROM_U_CALLBACK_SUBSTITUTE, 0, |
| 614 0, 0, &err); | 618 0, 0, &err); |
| 615 #else | 619 #else |
| 616 ucnv_setFromUCallBack( | 620 ucnv_setFromUCallBack( |
| 617 m_converterICU, m_needsGBKFallbacks ? gbkCallbackSubstitute | 621 m_converterICU, m_needsGBKFallbacks ? gbkCallbackSubstitute |
| 618 : UCNV_FROM_U_CALLBACK_SUBSTITUTE, | 622 : UCNV_FROM_U_CALLBACK_SUBSTITUTE, |
| 619 0, 0, 0, &err); | 623 0, 0, 0, &err); |
| 620 #endif | 624 #endif |
| 621 break; | 625 break; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 return encodeCommon(characters, length, handling); | 702 return encodeCommon(characters, length, handling); |
| 699 } | 703 } |
| 700 | 704 |
| 701 CString TextCodecICU::encode(const LChar* characters, | 705 CString TextCodecICU::encode(const LChar* characters, |
| 702 size_t length, | 706 size_t length, |
| 703 UnencodableHandling handling) { | 707 UnencodableHandling handling) { |
| 704 return encodeCommon(characters, length, handling); | 708 return encodeCommon(characters, length, handling); |
| 705 } | 709 } |
| 706 | 710 |
| 707 } // namespace WTF | 711 } // namespace WTF |
| OLD | NEW |