2 * \brief Header: Text conversion from one charset to another
8 #include "lib/global.h"
11 /*** typedefs(not structures) and defined constants **********************************************/
14 #define UNKNCHAR '\001'
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)*****************************************/
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
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
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
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 */
92 convert_to_display_c (int c
)
94 if (c
< 0 || c
>= 256)
100 convert_from_input_c (int c
)
102 if (c
< 0 || c
>= 256)
104 return conv_input
[c
];
107 #endif /* HAVE_CHARSET */
109 #endif /* MC__CHARSETS_H */