| 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 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 #include "wtf/Allocator.h" | 29 #include "wtf/Allocator.h" |
| 30 #include "wtf/Forward.h" | 30 #include "wtf/Forward.h" |
| 31 #include "wtf/WTFExport.h" | 31 #include "wtf/WTFExport.h" |
| 32 #include "wtf/text/TextCodec.h" | 32 #include "wtf/text/TextCodec.h" |
| 33 #include "wtf/text/Unicode.h" | 33 #include "wtf/text/Unicode.h" |
| 34 | 34 |
| 35 namespace WTF { | 35 namespace WTF { |
| 36 | 36 |
| 37 class WTF_EXPORT TextEncoding final { | 37 class WTF_EXPORT TextEncoding final { |
| 38 USING_FAST_MALLOC(TextEncoding); | 38 USING_FAST_MALLOC(TextEncoding); |
| 39 public: | |
| 40 TextEncoding() : m_name(0) { } | |
| 41 TextEncoding(const char* name); | |
| 42 TextEncoding(const String& name); | |
| 43 | 39 |
| 44 bool isValid() const { return m_name; } | 40 public: |
| 45 const char* name() const { return m_name; } | 41 TextEncoding() : m_name(0) {} |
| 46 bool usesVisualOrdering() const; | 42 TextEncoding(const char* name); |
| 47 const TextEncoding& closestByteBasedEquivalent() const; | 43 TextEncoding(const String& name); |
| 48 const TextEncoding& encodingForFormSubmission() const; | |
| 49 | 44 |
| 50 String decode(const char* str, size_t length) const | 45 bool isValid() const { return m_name; } |
| 51 { | 46 const char* name() const { return m_name; } |
| 52 bool ignored; | 47 bool usesVisualOrdering() const; |
| 53 return decode(str, length, false, ignored); | 48 const TextEncoding& closestByteBasedEquivalent() const; |
| 54 } | 49 const TextEncoding& encodingForFormSubmission() const; |
| 55 String decode(const char*, size_t length, bool stopOnError, bool& sawError)
const; | |
| 56 | 50 |
| 57 CString encode(const String&, UnencodableHandling) const; | 51 String decode(const char* str, size_t length) const { |
| 52 bool ignored; |
| 53 return decode(str, length, false, ignored); |
| 54 } |
| 55 String decode(const char*, |
| 56 size_t length, |
| 57 bool stopOnError, |
| 58 bool& sawError) const; |
| 58 | 59 |
| 59 bool isNonByteBasedEncoding() const; | 60 CString encode(const String&, UnencodableHandling) const; |
| 60 | 61 |
| 61 private: | 62 bool isNonByteBasedEncoding() const; |
| 62 bool isUTF7Encoding() const; | |
| 63 | 63 |
| 64 const char* m_name; | 64 private: |
| 65 bool isUTF7Encoding() const; |
| 66 |
| 67 const char* m_name; |
| 65 }; | 68 }; |
| 66 | 69 |
| 67 inline bool operator==(const TextEncoding& a, const TextEncoding& b) { return a.
name() == b.name(); } | 70 inline bool operator==(const TextEncoding& a, const TextEncoding& b) { |
| 68 inline bool operator!=(const TextEncoding& a, const TextEncoding& b) { return a.
name() != b.name(); } | 71 return a.name() == b.name(); |
| 72 } |
| 73 inline bool operator!=(const TextEncoding& a, const TextEncoding& b) { |
| 74 return a.name() != b.name(); |
| 75 } |
| 69 | 76 |
| 70 WTF_EXPORT const TextEncoding& ASCIIEncoding(); | 77 WTF_EXPORT const TextEncoding& ASCIIEncoding(); |
| 71 WTF_EXPORT const TextEncoding& Latin1Encoding(); | 78 WTF_EXPORT const TextEncoding& Latin1Encoding(); |
| 72 WTF_EXPORT const TextEncoding& UTF16BigEndianEncoding(); | 79 WTF_EXPORT const TextEncoding& UTF16BigEndianEncoding(); |
| 73 WTF_EXPORT const TextEncoding& UTF16LittleEndianEncoding(); | 80 WTF_EXPORT const TextEncoding& UTF16LittleEndianEncoding(); |
| 74 WTF_EXPORT const TextEncoding& UTF32BigEndianEncoding(); | 81 WTF_EXPORT const TextEncoding& UTF32BigEndianEncoding(); |
| 75 WTF_EXPORT const TextEncoding& UTF32LittleEndianEncoding(); | 82 WTF_EXPORT const TextEncoding& UTF32LittleEndianEncoding(); |
| 76 WTF_EXPORT const TextEncoding& UTF8Encoding(); | 83 WTF_EXPORT const TextEncoding& UTF8Encoding(); |
| 77 WTF_EXPORT const TextEncoding& WindowsLatin1Encoding(); | 84 WTF_EXPORT const TextEncoding& WindowsLatin1Encoding(); |
| 78 | 85 |
| 79 } // namespace WTF | 86 } // namespace WTF |
| 80 | 87 |
| 81 using WTF::ASCIIEncoding; | 88 using WTF::ASCIIEncoding; |
| 82 using WTF::Latin1Encoding; | 89 using WTF::Latin1Encoding; |
| 83 using WTF::UTF16BigEndianEncoding; | 90 using WTF::UTF16BigEndianEncoding; |
| 84 using WTF::UTF16LittleEndianEncoding; | 91 using WTF::UTF16LittleEndianEncoding; |
| 85 using WTF::UTF32BigEndianEncoding; | 92 using WTF::UTF32BigEndianEncoding; |
| 86 using WTF::UTF32LittleEndianEncoding; | 93 using WTF::UTF32LittleEndianEncoding; |
| 87 using WTF::UTF8Encoding; | 94 using WTF::UTF8Encoding; |
| 88 using WTF::WindowsLatin1Encoding; | 95 using WTF::WindowsLatin1Encoding; |
| 89 | 96 |
| 90 #endif // TextEncoding_h | 97 #endif // TextEncoding_h |
| OLD | NEW |