Editor: sync with new global config location (user menu and syntax files).
[midnight-commander.git] / src / charsets.h
blobc69256b32e1bb17a028b037fd4499587f3029013
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 #define CHARSETS_INDEX "mc.charsets"
14 extern int n_codepages;
16 extern unsigned char conv_displ[256];
17 extern unsigned char conv_input[256];
19 struct codepage_desc {
20 char *id;
21 char *name;
24 extern const char *cp_display;
25 extern const char *cp_source;
26 extern struct codepage_desc *codepages;
28 const char *get_codepage_id (const int n);
29 int get_codepage_index (const char *id);
30 int load_codepages_list (void);
31 void free_codepages_list (void);
32 const char *init_translation_table (int cpsource, int cpdisplay);
33 void convert_to_display (char *str);
34 void convert_from_input (char *str);
35 void convert_string (unsigned char *str);
37 * Converter from utf to selected codepage
38 * param str, utf char
39 * return char in needle codepage (by global int source_codepage)
41 unsigned char convert_from_utf_to_current (const char *str);
43 * Converter from utf to selected codepage
44 * param input_char, gunichar
45 * return char in needle codepage (by global int source_codepage)
47 unsigned char convert_from_utf_to_current_c (const int input_char);
49 * Converter from selected codepage 8-bit
50 * param char input_char
51 * return int utf char
53 int convert_from_8bit_to_utf_c (const char input_char);
55 * Converter from display codepage 8-bit to utf-8
56 * param char input_char
57 * return int utf char
59 int convert_from_8bit_to_utf_c2 (const char input_char);
61 GString *str_convert_to_input (char *str);
62 GString *str_nconvert_to_input (char *str, int len);
64 GString *str_convert_to_display (char *str);
65 GString *str_nconvert_to_display (char *str, int len);
67 /* Convert single characters */
68 static inline int
69 convert_to_display_c (int c)
71 if (c < 0 || c >= 256)
72 return c;
73 return conv_displ[c];
76 static inline int
77 convert_from_input_c (int c)
79 if (c < 0 || c >= 256)
80 return c;
81 return conv_input[c];
84 #else /* !HAVE_CHARSET */
86 #define convert_to_display_c(c) (c)
87 #define convert_from_input_c(c) (c)
88 #define convert_to_display(str) do {} while (0)
89 #define convert_from_input(str) do {} while (0)
91 #endif /* HAVE_CHARSET */
93 #endif