Merge branch 'scintilla-update-342'
[geany-mirror.git] / src / encodings.h
blob645d39e5ccd48c709b4e276c9ac3dbdf947a3dc8
1 /*
2 * encodings.h - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2005-2012 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2006-2012 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 along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 /**
24 * @file encodings.h
25 * Encoding conversion and Byte Order Mark (BOM) handling.
26 **/
29 * Modified by the gedit Team, 2002. See the gedit AUTHORS file for a
30 * list of people on the gedit Team.
31 * See the gedit ChangeLog files for a list of changes.
34 /* Stolen from anjuta */
36 #ifndef GEANY_ENCODINGS_H
37 #define GEANY_ENCODINGS_H
39 G_BEGIN_DECLS
41 typedef enum
43 NONE = 0,
44 WESTEUROPEAN,
45 EASTEUROPEAN,
46 EASTASIAN,
47 ASIAN,
48 MIDDLEEASTERN,
49 UNICODE,
51 GEANY_ENCODING_GROUPS_MAX
52 } GeanyEncodingGroup;
55 /** Structure to represent an encoding to be used in Geany. */
56 typedef struct
58 /** The index of the encoding, must be one of GeanyEncodingIndex. */
59 gint idx;
60 /** Internally used member for grouping */
61 gint order;
62 /** Internally used member for grouping */
63 GeanyEncodingGroup group;
64 /** String representation of the encoding, e.g. "ISO-8859-3" */
65 const gchar *charset;
66 /** Translatable and descriptive name of the encoding, e.g. "South European" */
67 const gchar *name;
68 } GeanyEncoding;
71 const GeanyEncoding* encodings_get_from_charset(const gchar *charset);
72 const GeanyEncoding* encodings_get_from_index(gint idx);
74 gchar* encodings_to_string(const GeanyEncoding* enc);
75 const gchar* encodings_get_charset(const GeanyEncoding* enc);
76 const gchar* encodings_get_charset_from_index(gint idx);
78 void encodings_select_radio_item(const gchar *charset);
80 void encodings_init(void);
81 void encodings_finalize(void);
83 GtkTreeStore *encodings_encoding_store_new(gboolean has_detect);
85 gint encodings_encoding_store_get_encoding(GtkTreeStore *store, GtkTreeIter *iter);
87 gboolean encodings_encoding_store_get_iter(GtkTreeStore *store, GtkTreeIter *iter, gint enc);
89 void encodings_encoding_store_cell_data_func(GtkCellLayout *cell_layout, GtkCellRenderer *cell,
90 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data);
92 gchar *encodings_convert_to_utf8(const gchar *buffer, gssize size, gchar **used_encoding);
94 /* Converts a string from the given charset to UTF-8.
95 * If fast is set, no further checks are performed. */
96 gchar *encodings_convert_to_utf8_from_charset(const gchar *buffer, gssize size,
97 const gchar *charset, gboolean fast);
99 gboolean encodings_is_unicode_charset(const gchar *string);
101 gboolean encodings_convert_to_utf8_auto(gchar **buf, gsize *size, const gchar *forced_enc,
102 gchar **used_encoding, gboolean *has_bom, gboolean *partial);
105 * The original versions of the following tables are taken from profterm
107 * Copyright (C) 2002 Red Hat, Inc.
111 * @enum GeanyEncodingIndex
112 * List of known and supported encodings.
114 typedef enum
116 GEANY_ENCODING_ISO_8859_1,
117 GEANY_ENCODING_ISO_8859_2,
118 GEANY_ENCODING_ISO_8859_3,
119 GEANY_ENCODING_ISO_8859_4,
120 GEANY_ENCODING_ISO_8859_5,
121 GEANY_ENCODING_ISO_8859_6,
122 GEANY_ENCODING_ISO_8859_7,
123 GEANY_ENCODING_ISO_8859_8,
124 GEANY_ENCODING_ISO_8859_8_I,
125 GEANY_ENCODING_ISO_8859_9,
126 GEANY_ENCODING_ISO_8859_10,
127 GEANY_ENCODING_ISO_8859_13,
128 GEANY_ENCODING_ISO_8859_14,
129 GEANY_ENCODING_ISO_8859_15,
130 GEANY_ENCODING_ISO_8859_16,
132 GEANY_ENCODING_UTF_7,
133 GEANY_ENCODING_UTF_8,
134 GEANY_ENCODING_UTF_16LE,
135 GEANY_ENCODING_UTF_16BE,
136 GEANY_ENCODING_UCS_2LE,
137 GEANY_ENCODING_UCS_2BE,
138 GEANY_ENCODING_UTF_32LE,
139 GEANY_ENCODING_UTF_32BE,
141 GEANY_ENCODING_ARMSCII_8,
142 GEANY_ENCODING_BIG5,
143 GEANY_ENCODING_BIG5_HKSCS,
144 GEANY_ENCODING_CP_866,
146 GEANY_ENCODING_EUC_JP,
147 GEANY_ENCODING_EUC_KR,
148 GEANY_ENCODING_EUC_TW,
150 GEANY_ENCODING_GB18030,
151 GEANY_ENCODING_GB2312,
152 GEANY_ENCODING_GBK,
153 GEANY_ENCODING_GEOSTD8,
154 GEANY_ENCODING_HZ,
156 GEANY_ENCODING_IBM_850,
157 GEANY_ENCODING_IBM_852,
158 GEANY_ENCODING_IBM_855,
159 GEANY_ENCODING_IBM_857,
160 GEANY_ENCODING_IBM_862,
161 GEANY_ENCODING_IBM_864,
163 GEANY_ENCODING_ISO_2022_JP,
164 GEANY_ENCODING_ISO_2022_KR,
165 GEANY_ENCODING_ISO_IR_111,
166 GEANY_ENCODING_JOHAB,
167 GEANY_ENCODING_KOI8_R,
168 GEANY_ENCODING_KOI8_U,
170 GEANY_ENCODING_SHIFT_JIS,
171 GEANY_ENCODING_TCVN,
172 GEANY_ENCODING_TIS_620,
173 GEANY_ENCODING_UHC,
174 GEANY_ENCODING_VISCII,
176 GEANY_ENCODING_WINDOWS_1250,
177 GEANY_ENCODING_WINDOWS_1251,
178 GEANY_ENCODING_WINDOWS_1252,
179 GEANY_ENCODING_WINDOWS_1253,
180 GEANY_ENCODING_WINDOWS_1254,
181 GEANY_ENCODING_WINDOWS_1255,
182 GEANY_ENCODING_WINDOWS_1256,
183 GEANY_ENCODING_WINDOWS_1257,
184 GEANY_ENCODING_WINDOWS_1258,
186 GEANY_ENCODING_NONE,
187 GEANY_ENCODING_CP_932,
189 GEANY_ENCODINGS_MAX
190 } GeanyEncodingIndex;
193 extern GeanyEncoding encodings[GEANY_ENCODINGS_MAX];
196 GeanyEncodingIndex encodings_scan_unicode_bom(const gchar *string, gsize len, guint *bom_len);
198 GeanyEncodingIndex encodings_get_idx_from_charset(const gchar *charset);
200 G_END_DECLS
202 #endif