| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com> | 3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com> |
| 4 * Copyright (C) 2007-2009 Torch Mobile, Inc. | 4 * Copyright (C) 2007-2009 Torch Mobile, Inc. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
| 8 * are met: | 8 * are met: |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 static const TextEncoding& UTF7Encoding() | 40 static const TextEncoding& UTF7Encoding() |
| 41 { | 41 { |
| 42 static TextEncoding globalUTF7Encoding("UTF-7"); | 42 static TextEncoding globalUTF7Encoding("UTF-7"); |
| 43 return globalUTF7Encoding; | 43 return globalUTF7Encoding; |
| 44 } | 44 } |
| 45 | 45 |
| 46 TextEncoding::TextEncoding(const char* name) | 46 TextEncoding::TextEncoding(const char* name) |
| 47 : m_name(atomicCanonicalTextEncodingName(name)) | 47 : m_name(atomicCanonicalTextEncodingName(name)) |
| 48 , m_backslashAsCurrencySymbol(backslashAsCurrencySymbol()) | 48 , m_backslashAsCurrencySymbol(backslashAsCurrencySymbol()) |
| 49 { | 49 { |
| 50 // Aliases are valid, but not "replacement" itself. |
| 51 if (m_name && isReplacementEncoding(name)) |
| 52 m_name = 0; |
| 50 } | 53 } |
| 51 | 54 |
| 52 TextEncoding::TextEncoding(const String& name) | 55 TextEncoding::TextEncoding(const String& name) |
| 53 : m_name(atomicCanonicalTextEncodingName(name)) | 56 : m_name(atomicCanonicalTextEncodingName(name)) |
| 54 , m_backslashAsCurrencySymbol(backslashAsCurrencySymbol()) | 57 , m_backslashAsCurrencySymbol(backslashAsCurrencySymbol()) |
| 55 { | 58 { |
| 59 // Aliases are valid, but not "replacement" itself. |
| 60 if (m_name && isReplacementEncoding(name)) |
| 61 m_name = 0; |
| 56 } | 62 } |
| 57 | 63 |
| 58 String TextEncoding::decode(const char* data, size_t length, bool stopOnError, b
ool& sawError) const | 64 String TextEncoding::decode(const char* data, size_t length, bool stopOnError, b
ool& sawError) const |
| 59 { | 65 { |
| 60 if (!m_name) | 66 if (!m_name) |
| 61 return String(); | 67 return String(); |
| 62 | 68 |
| 63 return newTextCodec(*this)->decode(data, length, DataEOF, stopOnError, sawEr
ror); | 69 return newTextCodec(*this)->decode(data, length, DataEOF, stopOnError, sawEr
ror); |
| 64 } | 70 } |
| 65 | 71 |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 return globalUTF8Encoding; | 222 return globalUTF8Encoding; |
| 217 } | 223 } |
| 218 | 224 |
| 219 const TextEncoding& WindowsLatin1Encoding() | 225 const TextEncoding& WindowsLatin1Encoding() |
| 220 { | 226 { |
| 221 static TextEncoding globalWindowsLatin1Encoding("WinLatin1"); | 227 static TextEncoding globalWindowsLatin1Encoding("WinLatin1"); |
| 222 return globalWindowsLatin1Encoding; | 228 return globalWindowsLatin1Encoding; |
| 223 } | 229 } |
| 224 | 230 |
| 225 } // namespace WTF | 231 } // namespace WTF |
| OLD | NEW |