2004-12-03 22:17:46 +03:00
|
|
|
#ifndef MC_CHARSETS_H
|
|
|
|
#define MC_CHARSETS_H
|
2001-05-31 05:27:20 +04:00
|
|
|
|
2002-10-31 02:14:26 +03:00
|
|
|
#ifdef HAVE_CHARSET
|
|
|
|
|
2001-05-31 05:27:20 +04:00
|
|
|
#define UNKNCHAR '\001'
|
|
|
|
|
2001-06-08 02:36:45 +04:00
|
|
|
#define CHARSETS_INDEX "mc.charsets"
|
2001-05-31 05:27:20 +04:00
|
|
|
extern int n_codepages;
|
|
|
|
|
2002-10-31 02:14:26 +03:00
|
|
|
extern unsigned char conv_displ[256];
|
|
|
|
extern unsigned char conv_input[256];
|
2001-05-31 05:27:20 +04:00
|
|
|
|
|
|
|
struct codepage_desc {
|
2004-08-30 14:38:00 +04:00
|
|
|
char *id;
|
|
|
|
char *name;
|
2001-05-31 05:27:20 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct codepage_desc *codepages;
|
|
|
|
|
2004-08-30 02:38:06 +04:00
|
|
|
const char *get_codepage_id (int n);
|
2002-10-31 02:14:26 +03:00
|
|
|
int get_codepage_index (const char *id);
|
|
|
|
int load_codepages_list (void);
|
|
|
|
void free_codepages_list (void);
|
2004-08-30 02:38:06 +04:00
|
|
|
const char *init_translation_table (int cpsource, int cpdisplay);
|
2002-10-31 02:14:26 +03:00
|
|
|
void convert_to_display (char *str);
|
|
|
|
void convert_from_input (char *str);
|
|
|
|
void convert_string (unsigned char *str);
|
2009-04-17 14:27:59 +04:00
|
|
|
/*
|
|
|
|
* Converter from utf to selected codepage
|
|
|
|
* param str, utf char
|
|
|
|
* return char in needle codepage (by global int source_codepage)
|
|
|
|
*/
|
2009-04-17 01:26:08 +04:00
|
|
|
unsigned char convert_from_utf_to_current (const char *str);
|
2009-04-17 14:27:59 +04:00
|
|
|
/*
|
|
|
|
* Converter from utf to selected codepage
|
|
|
|
* param input_char, gunichar
|
|
|
|
* return char in needle codepage (by global int source_codepage)
|
|
|
|
*/
|
2009-04-17 01:26:08 +04:00
|
|
|
unsigned char convert_from_utf_to_current_c (const int input_char);
|
2009-04-20 00:28:00 +04:00
|
|
|
/*
|
|
|
|
* Converter from selected codepage 8-bit
|
|
|
|
* param char input_char
|
|
|
|
* return int utf char
|
|
|
|
*/
|
|
|
|
int convert_from_8bit_to_utf_c (const char input_char);
|
|
|
|
|
2002-10-31 02:42:21 +03:00
|
|
|
/* Convert single characters */
|
|
|
|
static inline int
|
|
|
|
convert_to_display_c (int c)
|
|
|
|
{
|
|
|
|
if (c < 0 || c >= 256)
|
|
|
|
return c;
|
|
|
|
return conv_displ[c];
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
convert_from_input_c (int c)
|
|
|
|
{
|
|
|
|
if (c < 0 || c >= 256)
|
|
|
|
return c;
|
|
|
|
return conv_input[c];
|
|
|
|
}
|
|
|
|
|
2002-10-31 02:14:26 +03:00
|
|
|
#else /* !HAVE_CHARSET */
|
2002-10-31 02:42:21 +03:00
|
|
|
|
|
|
|
#define convert_to_display_c(c) (c)
|
|
|
|
#define convert_from_input_c(c) (c)
|
|
|
|
#define convert_to_display(str) do {} while (0)
|
|
|
|
#define convert_from_input(str) do {} while (0)
|
|
|
|
|
2002-10-31 02:14:26 +03:00
|
|
|
#endif /* HAVE_CHARSET */
|
2001-05-31 05:27:20 +04:00
|
|
|
|
2004-12-03 22:17:46 +03:00
|
|
|
#endif
|