c family: Add support for digraphs
[geany-mirror.git] / src / encodings.h
blob8beb79c94f98bc50aa03d79e4c347262fc34bc4c
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 1
39 #include "gtkcompat.h"
41 G_BEGIN_DECLS
43 typedef enum
45 NONE = 0,
46 WESTEUROPEAN,
47 EASTEUROPEAN,
48 EASTASIAN,
49 ASIAN,
50 MIDDLEEASTERN,
51 UNICODE,
53 GEANY_ENCODING_GROUPS_MAX
54 } GeanyEncodingGroup;
57 * The original versions of the following tables are taken from profterm
59 * Copyright (C) 2002 Red Hat, Inc.
62 /**
63 * @enum GeanyEncodingIndex
64 * List of known and supported encodings.
65 **/
66 typedef enum
68 GEANY_ENCODING_ISO_8859_1,
69 GEANY_ENCODING_ISO_8859_2,
70 GEANY_ENCODING_ISO_8859_3,
71 GEANY_ENCODING_ISO_8859_4,
72 GEANY_ENCODING_ISO_8859_5,
73 GEANY_ENCODING_ISO_8859_6,
74 GEANY_ENCODING_ISO_8859_7,
75 GEANY_ENCODING_ISO_8859_8,
76 GEANY_ENCODING_ISO_8859_8_I,
77 GEANY_ENCODING_ISO_8859_9,
78 GEANY_ENCODING_ISO_8859_10,
79 GEANY_ENCODING_ISO_8859_13,
80 GEANY_ENCODING_ISO_8859_14,
81 GEANY_ENCODING_ISO_8859_15,
82 GEANY_ENCODING_ISO_8859_16,
84 GEANY_ENCODING_UTF_7,
85 GEANY_ENCODING_UTF_8,
86 GEANY_ENCODING_UTF_16LE,
87 GEANY_ENCODING_UTF_16BE,
88 GEANY_ENCODING_UCS_2LE,
89 GEANY_ENCODING_UCS_2BE,
90 GEANY_ENCODING_UTF_32LE,
91 GEANY_ENCODING_UTF_32BE,
93 GEANY_ENCODING_ARMSCII_8,
94 GEANY_ENCODING_BIG5,
95 GEANY_ENCODING_BIG5_HKSCS,
96 GEANY_ENCODING_CP_866,
98 GEANY_ENCODING_EUC_JP,
99 GEANY_ENCODING_EUC_KR,
100 GEANY_ENCODING_EUC_TW,
102 GEANY_ENCODING_GB18030,
103 GEANY_ENCODING_GB2312,
104 GEANY_ENCODING_GBK,
105 GEANY_ENCODING_GEOSTD8,
106 GEANY_ENCODING_HZ,
108 GEANY_ENCODING_IBM_850,
109 GEANY_ENCODING_IBM_852,
110 GEANY_ENCODING_IBM_855,
111 GEANY_ENCODING_IBM_857,
112 GEANY_ENCODING_IBM_862,
113 GEANY_ENCODING_IBM_864,
115 GEANY_ENCODING_ISO_2022_JP,
116 GEANY_ENCODING_ISO_2022_KR,
117 GEANY_ENCODING_ISO_IR_111,
118 GEANY_ENCODING_JOHAB,
119 GEANY_ENCODING_KOI8_R,
120 GEANY_ENCODING_KOI8_U,
122 GEANY_ENCODING_SHIFT_JIS,
123 GEANY_ENCODING_TCVN,
124 GEANY_ENCODING_TIS_620,
125 GEANY_ENCODING_UHC,
126 GEANY_ENCODING_VISCII,
128 GEANY_ENCODING_WINDOWS_1250,
129 GEANY_ENCODING_WINDOWS_1251,
130 GEANY_ENCODING_WINDOWS_1252,
131 GEANY_ENCODING_WINDOWS_1253,
132 GEANY_ENCODING_WINDOWS_1254,
133 GEANY_ENCODING_WINDOWS_1255,
134 GEANY_ENCODING_WINDOWS_1256,
135 GEANY_ENCODING_WINDOWS_1257,
136 GEANY_ENCODING_WINDOWS_1258,
138 GEANY_ENCODING_NONE,
139 GEANY_ENCODING_CP_932,
141 GEANY_ENCODINGS_MAX
142 } GeanyEncodingIndex;
144 /** Structure to represent an encoding to be used in Geany. */
145 typedef struct
147 /** The index of the encoding, must be one of GeanyEncodingIndex. */
148 gint idx;
149 /** Internally used member for grouping */
150 gint order;
151 /** Internally used member for grouping */
152 GeanyEncodingGroup group;
153 /** String representation of the encoding, e.g. "ISO-8859-3" */
154 const gchar *charset;
155 /** Translatable and descriptive name of the encoding, e.g. "South European" */
156 const gchar *name;
157 } GeanyEncoding;
160 gchar *encodings_convert_to_utf8(const gchar *buffer, gssize size, gchar **used_encoding);
162 /* Converts a string from the given charset to UTF-8.
163 * If fast is set, no further checks are performed. */
164 gchar *encodings_convert_to_utf8_from_charset(const gchar *buffer, gssize size,
165 const gchar *charset, gboolean fast);
167 const gchar* encodings_get_charset_from_index(gint idx);
170 #ifdef GEANY_PRIVATE
172 const GeanyEncoding* encodings_get_from_charset(const gchar *charset);
173 const GeanyEncoding* encodings_get_from_index(gint idx);
175 gchar* encodings_to_string(const GeanyEncoding* enc);
176 const gchar* encodings_get_charset(const GeanyEncoding* enc);
178 void encodings_select_radio_item(const gchar *charset);
180 void encodings_init(void);
181 void encodings_finalize(void);
183 GtkTreeStore *encodings_encoding_store_new(gboolean has_detect);
185 gint encodings_encoding_store_get_encoding(GtkTreeStore *store, GtkTreeIter *iter);
187 gboolean encodings_encoding_store_get_iter(GtkTreeStore *store, GtkTreeIter *iter, gint enc);
189 void encodings_encoding_store_cell_data_func(GtkCellLayout *cell_layout, GtkCellRenderer *cell,
190 GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data);
192 gboolean encodings_is_unicode_charset(const gchar *string);
194 gboolean encodings_convert_to_utf8_auto(gchar **buf, gsize *size, const gchar *forced_enc,
195 gchar **used_encoding, gboolean *has_bom, gboolean *partial);
198 extern GeanyEncoding encodings[GEANY_ENCODINGS_MAX];
201 GeanyEncodingIndex encodings_scan_unicode_bom(const gchar *string, gsize len, guint *bom_len);
203 GeanyEncodingIndex encodings_get_idx_from_charset(const gchar *charset);
205 #endif /* GEANY_PRIVATE */
207 G_END_DECLS
209 #endif /* GEANY_ENCODINGS_H */