misc/mc.ext.in: added 3gp video
[free-mc.git] / src / charsets.h
blob98186b8cbef6146a01b50c3b516305a6c6e595df
2 /** \file charsets.h
3 * \brief Header: Text conversion from one charset to another
4 */
6 #ifndef MC_CHARSETS_H
7 #define MC_CHARSETS_H
9 #ifdef HAVE_CHARSET
11 #define UNKNCHAR '\001'
13 extern int n_codepages;
15 extern unsigned char conv_displ[256];
16 extern unsigned char conv_input[256];
18 struct codepage_desc {
19 char *id;
20 char *name;
23 extern const char *cp_display;
24 extern const char *cp_source;
25 extern struct codepage_desc *codepages;
27 const char *get_codepage_id (const int n);
28 int get_codepage_index (const char *id);
29 int load_codepages_list (void);
30 void free_codepages_list (void);
31 const char *init_translation_table (int cpsource, int cpdisplay);
32 void convert_to_display (char *str);
33 void convert_from_input (char *str);
34 void convert_string (unsigned char *str);
36 * Converter from utf to selected codepage
37 * param str, utf char
38 * return char in needle codepage (by global int source_codepage)
40 unsigned char convert_from_utf_to_current (const char *str);
42 * Converter from utf to selected codepage
43 * param input_char, gunichar
44 * return char in needle codepage (by global int source_codepage)
46 unsigned char convert_from_utf_to_current_c (const int input_char, GIConv conv);
48 * Converter from selected codepage 8-bit
49 * param char input_char, GIConv converter
50 * return int utf char
52 int convert_from_8bit_to_utf_c (const char input_char, GIConv conv);
54 * Converter from display codepage 8-bit to utf-8
55 * param char input_char, GIConv converter
56 * return int utf char
58 int convert_from_8bit_to_utf_c2 (const char input_char);
60 GString *str_convert_to_input (char *str);
61 GString *str_nconvert_to_input (char *str, int len);
63 GString *str_convert_to_display (char *str);
64 GString *str_nconvert_to_display (char *str, int len);
66 /* Convert single characters */
67 static inline int
68 convert_to_display_c (int c)
70 if (c < 0 || c >= 256)
71 return c;
72 return conv_displ[c];
75 static inline int
76 convert_from_input_c (int c)
78 if (c < 0 || c >= 256)
79 return c;
80 return conv_input[c];
83 #else /* !HAVE_CHARSET */
85 #define convert_to_display_c(c) (c)
86 #define convert_from_input_c(c) (c)
87 #define convert_to_display(str) do {} while (0)
88 #define convert_from_input(str) do {} while (0)
90 #endif /* HAVE_CHARSET */
92 #endif