| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006 Apple Computer, 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 12 matching lines...) Expand all Loading... |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "wtf/text/TextCodec.h" | 27 #include "wtf/text/TextCodec.h" |
| 28 | 28 |
| 29 #include "wtf/StringExtras.h" | 29 #include "wtf/StringExtras.h" |
| 30 | 30 |
| 31 namespace WTF { | 31 namespace WTF { |
| 32 | 32 |
| 33 TextCodec::~TextCodec() | 33 TextCodec::~TextCodec() {} |
| 34 { | 34 |
| 35 int TextCodec::getUnencodableReplacement( |
| 36 unsigned codePoint, |
| 37 UnencodableHandling handling, |
| 38 UnencodableReplacementArray replacement) { |
| 39 switch (handling) { |
| 40 case QuestionMarksForUnencodables: |
| 41 replacement[0] = '?'; |
| 42 replacement[1] = 0; |
| 43 return 1; |
| 44 case EntitiesForUnencodables: |
| 45 snprintf(replacement, sizeof(UnencodableReplacementArray), "&#%u;", |
| 46 codePoint); |
| 47 return static_cast<int>(strlen(replacement)); |
| 48 case URLEncodedEntitiesForUnencodables: |
| 49 snprintf(replacement, sizeof(UnencodableReplacementArray), |
| 50 "%%26%%23%u%%3B", codePoint); |
| 51 return static_cast<int>(strlen(replacement)); |
| 52 } |
| 53 ASSERT_NOT_REACHED(); |
| 54 replacement[0] = 0; |
| 55 return 0; |
| 35 } | 56 } |
| 36 | 57 |
| 37 int TextCodec::getUnencodableReplacement(unsigned codePoint, UnencodableHandling
handling, UnencodableReplacementArray replacement) | 58 } // namespace WTF |
| 38 { | |
| 39 switch (handling) { | |
| 40 case QuestionMarksForUnencodables: | |
| 41 replacement[0] = '?'; | |
| 42 replacement[1] = 0; | |
| 43 return 1; | |
| 44 case EntitiesForUnencodables: | |
| 45 snprintf(replacement, sizeof(UnencodableReplacementArray), "&#%u;", code
Point); | |
| 46 return static_cast<int>(strlen(replacement)); | |
| 47 case URLEncodedEntitiesForUnencodables: | |
| 48 snprintf(replacement, sizeof(UnencodableReplacementArray), "%%26%%23%u%%
3B", codePoint); | |
| 49 return static_cast<int>(strlen(replacement)); | |
| 50 } | |
| 51 ASSERT_NOT_REACHED(); | |
| 52 replacement[0] = 0; | |
| 53 return 0; | |
| 54 } | |
| 55 | |
| 56 } // namespace WTF | |
| OLD | NEW |