| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 306 |
| 307 class ErrorCallbackSetter final { | 307 class ErrorCallbackSetter final { |
| 308 STACK_ALLOCATED(); | 308 STACK_ALLOCATED(); |
| 309 public: | 309 public: |
| 310 ErrorCallbackSetter(UConverter* converter, bool stopOnError) | 310 ErrorCallbackSetter(UConverter* converter, bool stopOnError) |
| 311 : m_converter(converter) | 311 : m_converter(converter) |
| 312 , m_shouldStopOnEncodingErrors(stopOnError) | 312 , m_shouldStopOnEncodingErrors(stopOnError) |
| 313 { | 313 { |
| 314 if (m_shouldStopOnEncodingErrors) { | 314 if (m_shouldStopOnEncodingErrors) { |
| 315 UErrorCode err = U_ZERO_ERROR; | 315 UErrorCode err = U_ZERO_ERROR; |
| 316 ucnv_setToUCallBack(m_converter, UCNV_TO_U_CALLBACK_SUBSTITUTE, | 316 ucnv_setToUCallBack(m_converter, UCNV_TO_U_CALLBACK_STOP, 0, &m_save
dAction, &m_savedContext, &err); |
| 317 UCNV_SUB_STOP_ON_ILLEGAL, &m_savedAction, | 317 DCHECK_EQ(err, U_ZERO_ERROR); |
| 318 &m_savedContext, &err); | |
| 319 ASSERT(err == U_ZERO_ERROR); | |
| 320 } | 318 } |
| 321 } | 319 } |
| 322 ~ErrorCallbackSetter() | 320 ~ErrorCallbackSetter() |
| 323 { | 321 { |
| 324 if (m_shouldStopOnEncodingErrors) { | 322 if (m_shouldStopOnEncodingErrors) { |
| 325 UErrorCode err = U_ZERO_ERROR; | 323 UErrorCode err = U_ZERO_ERROR; |
| 326 const void* oldContext; | 324 const void* oldContext; |
| 327 UConverterToUCallback oldAction; | 325 UConverterToUCallback oldAction; |
| 328 ucnv_setToUCallBack(m_converter, m_savedAction, m_savedContext, &old
Action, &oldContext, &err); | 326 ucnv_setToUCallBack(m_converter, m_savedAction, m_savedContext, &old
Action, &oldContext, &err); |
| 329 ASSERT(oldAction == UCNV_TO_U_CALLBACK_SUBSTITUTE); | 327 DCHECK_EQ(oldAction, UCNV_TO_U_CALLBACK_STOP); |
| 330 ASSERT(!strcmp(static_cast<const char*>(oldContext), UCNV_SUB_STOP_O
N_ILLEGAL)); | 328 DCHECK(!oldContext); |
| 331 ASSERT(err == U_ZERO_ERROR); | 329 DCHECK_EQ(err, U_ZERO_ERROR); |
| 332 } | 330 } |
| 333 } | 331 } |
| 334 | 332 |
| 335 private: | 333 private: |
| 336 UConverter* m_converter; | 334 UConverter* m_converter; |
| 337 bool m_shouldStopOnEncodingErrors; | 335 bool m_shouldStopOnEncodingErrors; |
| 338 const void* m_savedContext; | 336 const void* m_savedContext; |
| 339 UConverterToUCallback m_savedAction; | 337 UConverterToUCallback m_savedAction; |
| 340 }; | 338 }; |
| 341 | 339 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 { | 608 { |
| 611 return encodeCommon(characters, length, handling); | 609 return encodeCommon(characters, length, handling); |
| 612 } | 610 } |
| 613 | 611 |
| 614 CString TextCodecICU::encode(const LChar* characters, size_t length, Unencodable
Handling handling) | 612 CString TextCodecICU::encode(const LChar* characters, size_t length, Unencodable
Handling handling) |
| 615 { | 613 { |
| 616 return encodeCommon(characters, length, handling); | 614 return encodeCommon(characters, length, handling); |
| 617 } | 615 } |
| 618 | 616 |
| 619 } // namespace WTF | 617 } // namespace WTF |
| OLD | NEW |