Added counter of ignored dirs.
[pantumic.git] / lib / charsets.h
blobbb1a5927117c38f4ac9c6adb5800437d50d741ab
1 /** \file charsets.h
2 * \brief Header: Text conversion from one charset to another
3 */
5 #ifndef MC__CHARSETS_H
6 #define MC__CHARSETS_H
8 #include "lib/global.h"
11 /*** typedefs(not structures) and defined constants **********************************************/
13 #ifdef HAVE_CHARSET
14 #define UNKNCHAR '\001'
15 #else
16 #define convert_to_display_c(c) (c)
17 #define convert_from_input_c(c) (c)
18 #define convert_to_display(str) do {} while (0)
19 #define convert_from_input(str) do {} while (0)
20 #endif /* HAVE_CHARSET */
22 /*** enums ***************************************************************************************/
24 /*** structures declarations (and typedefs of structures)*****************************************/
25 #ifdef HAVE_CHARSET
27 typedef struct
29 char *id;
30 char *name;
31 } codepage_desc;
33 /*** global variables defined in .c file *********************************************************/
35 extern unsigned char conv_displ[256];
36 extern unsigned char conv_input[256];
38 extern const char *cp_display;
39 extern const char *cp_source;
40 extern GPtrArray *codepages;
42 /*** declarations of public functions ************************************************************/
44 const char *get_codepage_id (const int n);
45 int get_codepage_index (const char *id);
46 void load_codepages_list (void);
47 void free_codepages_list (void);
48 gboolean is_supported_encoding (const char *encoding);
49 char *init_translation_table (int cpsource, int cpdisplay);
50 void convert_to_display (char *str);
51 void convert_from_input (char *str);
52 void convert_string (unsigned char *str);
55 * Converter from utf to selected codepage
56 * param str, utf char
57 * return char in needle codepage (by global int source_codepage)
59 unsigned char convert_from_utf_to_current (const char *str);
62 * Converter from utf to selected codepage
63 * param input_char, gunichar
64 * return char in needle codepage (by global int source_codepage)
66 unsigned char convert_from_utf_to_current_c (const int input_char, GIConv conv);
69 * Converter from selected codepage 8-bit
70 * param char input_char, GIConv converter
71 * return int utf char
73 int convert_from_8bit_to_utf_c (const char input_char, GIConv conv);
76 * Converter from display codepage 8-bit to utf-8
77 * param char input_char, GIConv converter
78 * return int utf char
80 int convert_from_8bit_to_utf_c2 (const char input_char);
82 GString *str_convert_to_input (char *str);
83 GString *str_nconvert_to_input (char *str, int len);
85 GString *str_convert_to_display (char *str);
86 GString *str_nconvert_to_display (char *str, int len);
88 /*** inline functions ****************************************************************************/
90 /* Convert single characters */
91 static inline int
92 convert_to_display_c (int c)
94 if (c < 0 || c >= 256)
95 return c;
96 return conv_displ[c];
99 static inline int
100 convert_from_input_c (int c)
102 if (c < 0 || c >= 256)
103 return c;
104 return conv_input[c];
107 #endif /* HAVE_CHARSET */
109 #endif /* MC__CHARSETS_H */