1/* 2 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. 3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com> 4 * Copyright (C) 2008 Jürg Billeter <j@bitron.ch> 5 * Copyright (C) 2009 Dominik Röttsches <dominik.roettsches@access-company.com> 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#ifndef TextCodecGTK_h 30#define TextCodecGTK_h 31 32#include <glib.h> 33#include "TextCodec.h" 34#include "TextEncoding.h" 35 36namespace WebCore { 37 38 class TextCodecGtk : public TextCodec { 39 public: 40 static void registerBaseEncodingNames(EncodingNameRegistrar); 41 static void registerBaseCodecs(TextCodecRegistrar); 42 43 static void registerExtendedEncodingNames(EncodingNameRegistrar); 44 static void registerExtendedCodecs(TextCodecRegistrar); 45 46 TextCodecGtk(const TextEncoding&); 47 virtual ~TextCodecGtk(); 48 49 virtual String decode(const char*, size_t length, bool flush, bool stopOnError, bool& sawError); 50 virtual CString encode(const UChar*, size_t length, UnencodableHandling); 51 52 private: 53 void createIConvDecoder() const; 54 void createIConvEncoder() const; 55 56 static void registerEncodingNames(EncodingNameRegistrar registrar, bool extended); 57 static void registerCodecs(TextCodecRegistrar registrar, bool extended); 58 static gboolean isEncodingAvailable(const gchar*); 59 60 TextEncoding m_encoding; 61 size_t m_numBufferedBytes; 62 unsigned char m_bufferedBytes[16]; // bigger than any single multi-byte character 63 mutable GIConv m_iconvDecoder; 64 mutable GIConv m_iconvEncoder; 65 66 static const gchar* m_internalEncodingName; 67 68 typedef const gchar* const codecAliasList[]; 69 70 // Unicode 71 static codecAliasList m_codecAliases_UTF_8; 72 73 // Western 74 static codecAliasList m_codecAliases_ISO_8859_1; 75 static codecAliasList m_codecAliases_MACROMAN; 76 77 // Japanese 78 static codecAliasList m_codecAliases_SHIFT_JIS; 79 static codecAliasList m_codecAliases_EUC_JP; 80 static codecAliasList m_codecAliases_ISO_2022_JP; 81 82 // Traditional Chinese 83 static codecAliasList m_codecAliases_BIG5; 84 static codecAliasList m_codecAliases_BIG5_HKSCS; 85 static codecAliasList m_codecAliases_CP950; 86 87 // Korean 88 static codecAliasList m_codecAliases_ISO_2022_KR; 89 static codecAliasList m_codecAliases_CP949; 90 static codecAliasList m_codecAliases_EUC_KR; 91 92 // Arabic 93 static codecAliasList m_codecAliases_ISO_8859_6; 94 static codecAliasList m_codecAliases_CP1256; 95 96 // Hebrew 97 static codecAliasList m_codecAliases_ISO_8859_8; 98 static codecAliasList m_codecAliases_CP1255; 99 100 // Greek 101 static codecAliasList m_codecAliases_ISO_8859_7; 102 static codecAliasList m_codecAliases_CP869; 103 static codecAliasList m_codecAliases_WINDOWS_1253; 104 105 // Cyrillic 106 static codecAliasList m_codecAliases_ISO_8859_5; 107 static codecAliasList m_codecAliases_KOI8_R; 108 static codecAliasList m_codecAliases_CP866; 109 static codecAliasList m_codecAliases_KOI8_U; 110 static codecAliasList m_codecAliases_WINDOWS_1251; 111 static codecAliasList m_codecAliases_MACCYRILLIC; 112 113 // Thai 114 static codecAliasList m_codecAliases_CP874; 115 static codecAliasList m_codecAliases_TIS_620; 116 117 // Simplified Chinese 118 static codecAliasList m_codecAliases_GBK; 119 static codecAliasList m_codecAliases_HZ; 120 static codecAliasList m_codecAliases_GB18030; 121 static codecAliasList m_codecAliases_EUC_CN; 122 static codecAliasList m_codecAliases_2312_80; 123 124 // Central European 125 static codecAliasList m_codecAliases_ISO_8859_2; 126 static codecAliasList m_codecAliases_CP1250; 127 static codecAliasList m_codecAliases_MACCENTRALEUROPE; 128 129 // Vietnamese 130 static codecAliasList m_codecAliases_CP1258; 131 132 // Turkish 133 static codecAliasList m_codecAliases_CP1254; 134 static codecAliasList m_codecAliases_ISO_8859_9; 135 136 // Baltic 137 static codecAliasList m_codecAliases_CP1257; 138 static codecAliasList m_codecAliases_ISO_8859_4; 139 140 static gconstpointer const m_iconvBaseCodecList[]; 141 static gconstpointer const m_iconvExtendedCodecList[]; 142 143 }; 144 145} // namespace WebCore 146 147#endif // TextCodecGTK_h 148