Cache G_TYPE_INSTANCE_GET_PRIVATE() result when initializing an
[geany-mirror.git] / src / encodings.h
blob82eb59e10bd51c6a2d3ff687202efeaa62d5918f
1 /*
2 * encodings.h - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2005-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2006-2010 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * $Id$
25 /**
26 * @file encodings.h
27 * Encoding conversion and Byte Order Mark (BOM) handling.
28 **/
31 * Modified by the gedit Team, 2002. See the gedit AUTHORS file for a
32 * list of people on the gedit Team.
33 * See the gedit ChangeLog files for a list of changes.
36 /* Stolen from anjuta */
38 #ifndef GEANY_ENCODINGS_H
39 #define GEANY_ENCODINGS_H
42 typedef enum
44 NONE = 0,
45 WESTEUROPEAN,
46 EASTEUROPEAN,
47 EASTASIAN,
48 ASIAN,
49 MIDDLEEASTERN,
50 UNICODE,
52 GEANY_ENCODING_GROUPS_MAX
53 } GeanyEncodingGroup;
56 /** Structure to represent an encoding to be used in Geany. */
57 typedef struct
59 /** The index of the encoding, must be one of GeanyEncodingIndex. */
60 gint idx;
61 /** Internally used member for grouping */
62 gint order;
63 /** Internally used member for grouping */
64 GeanyEncodingGroup group;
65 /** String representation of the encoding, e.g. "ISO-8859-3" */
66 gchar *charset;
67 /** Translatable and descriptive name of the encoding, e.g. "South European" */
68 gchar *name;
69 } GeanyEncoding;
72 const GeanyEncoding* encodings_get_from_charset(const gchar *charset);
73 const GeanyEncoding* encodings_get_from_index(gint idx);
75 gchar* encodings_to_string(const GeanyEncoding* enc);
76 const gchar* encodings_get_charset(const GeanyEncoding* enc);
77 const gchar* encodings_get_charset_from_index(gint idx);
79 void encodings_select_radio_item(const gchar *charset);
81 void encodings_init(void);
82 void encodings_finalize(void);
84 gchar *encodings_convert_to_utf8(const gchar *buffer, gsize size, gchar **used_encoding);
86 /* Converts a string from the given charset to UTF-8.
87 * If fast is set, no further checks are performed. */
88 gchar *encodings_convert_to_utf8_from_charset(const gchar *buffer, gsize size,
89 const gchar *charset, gboolean fast);
91 gboolean encodings_is_unicode_charset(const gchar *string);
95 * The original versions of the following tables are taken from profterm
97 * Copyright (C) 2002 Red Hat, Inc.
101 * @enum GeanyEncodingIndex
102 * List of known and supported encodings.
104 typedef enum
106 GEANY_ENCODING_ISO_8859_1,
107 GEANY_ENCODING_ISO_8859_2,
108 GEANY_ENCODING_ISO_8859_3,
109 GEANY_ENCODING_ISO_8859_4,
110 GEANY_ENCODING_ISO_8859_5,
111 GEANY_ENCODING_ISO_8859_6,
112 GEANY_ENCODING_ISO_8859_7,
113 GEANY_ENCODING_ISO_8859_8,
114 GEANY_ENCODING_ISO_8859_8_I,
115 GEANY_ENCODING_ISO_8859_9,
116 GEANY_ENCODING_ISO_8859_10,
117 GEANY_ENCODING_ISO_8859_13,
118 GEANY_ENCODING_ISO_8859_14,
119 GEANY_ENCODING_ISO_8859_15,
120 GEANY_ENCODING_ISO_8859_16,
122 GEANY_ENCODING_UTF_7,
123 GEANY_ENCODING_UTF_8,
124 GEANY_ENCODING_UTF_16LE,
125 GEANY_ENCODING_UTF_16BE,
126 GEANY_ENCODING_UCS_2LE,
127 GEANY_ENCODING_UCS_2BE,
128 GEANY_ENCODING_UTF_32LE,
129 GEANY_ENCODING_UTF_32BE,
131 GEANY_ENCODING_ARMSCII_8,
132 GEANY_ENCODING_BIG5,
133 GEANY_ENCODING_BIG5_HKSCS,
134 GEANY_ENCODING_CP_866,
136 GEANY_ENCODING_EUC_JP,
137 GEANY_ENCODING_EUC_KR,
138 GEANY_ENCODING_EUC_TW,
140 GEANY_ENCODING_GB18030,
141 GEANY_ENCODING_GB2312,
142 GEANY_ENCODING_GBK,
143 GEANY_ENCODING_GEOSTD8,
144 GEANY_ENCODING_HZ,
146 GEANY_ENCODING_IBM_850,
147 GEANY_ENCODING_IBM_852,
148 GEANY_ENCODING_IBM_855,
149 GEANY_ENCODING_IBM_857,
150 GEANY_ENCODING_IBM_862,
151 GEANY_ENCODING_IBM_864,
153 GEANY_ENCODING_ISO_2022_JP,
154 GEANY_ENCODING_ISO_2022_KR,
155 GEANY_ENCODING_ISO_IR_111,
156 GEANY_ENCODING_JOHAB,
157 GEANY_ENCODING_KOI8_R,
158 GEANY_ENCODING_KOI8_U,
160 GEANY_ENCODING_SHIFT_JIS,
161 GEANY_ENCODING_TCVN,
162 GEANY_ENCODING_TIS_620,
163 GEANY_ENCODING_UHC,
164 GEANY_ENCODING_VISCII,
166 GEANY_ENCODING_WINDOWS_1250,
167 GEANY_ENCODING_WINDOWS_1251,
168 GEANY_ENCODING_WINDOWS_1252,
169 GEANY_ENCODING_WINDOWS_1253,
170 GEANY_ENCODING_WINDOWS_1254,
171 GEANY_ENCODING_WINDOWS_1255,
172 GEANY_ENCODING_WINDOWS_1256,
173 GEANY_ENCODING_WINDOWS_1257,
174 GEANY_ENCODING_WINDOWS_1258,
176 GEANY_ENCODING_NONE,
177 GEANY_ENCODING_CP_932,
179 GEANY_ENCODINGS_MAX
180 } GeanyEncodingIndex;
183 extern GeanyEncoding encodings[GEANY_ENCODINGS_MAX];
186 GeanyEncodingIndex encodings_scan_unicode_bom(const gchar *string, gsize len, guint *bom_len);
188 GeanyEncodingIndex encodings_get_idx_from_charset(const gchar *charset);
190 #endif