#ifndef MC_CHARSETS_H
#define MC_CHARSETS_H

#define BINARY_CHAR_OFFSET 0xFFE00

#ifdef HAVE_CHARSET

#define UNKNCHAR '\001'

#define CHARSETS_INDEX "mc.charsets"
#define OTHER_8BIT "Other_8_bit"


extern int n_codepages;

extern unsigned char conv_displ[256];
extern unsigned char conv_input[256];

extern int glbl_cpsource_isUTF, glbl_cpdisplay_isUTF;

struct codepage_desc {
    char *id;
    char *name;
};

extern struct codepage_desc *codepages;

#include <iconv.h>
extern char translate_character(iconv_t cd, char c);
extern char errbuf[255];

const char *get_codepage_id (int n);
int get_codepage_index (const char *id);
int load_codepages_list (void);
void free_codepages_list (void);
const char *init_translation_table (int cpsource, int cpdisplay);
void convert_to_display (char *str);
void convert_from_input (char *str);
void convert_string (unsigned char *str);


char *convert_to_display_w (char *str);
char *convert_from_input_w (char *str);

char *from_cp1_to_cp2(int _cp1,int _cp2, char *c);

/* Convert single characters */
int convert_to_display_c (int c);
int convert_from_input_c (int c);

int one_from_sourceCP_to_UTC4INTERNAL(char *c);
int one_from_displayCP_to_UTC4INTERNAL(char *c);

void f_log(const char *fmt, ...);
void f_logb(void *data, int len);


#else /* !HAVE_CHARSET */

#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)

#endif /* HAVE_CHARSET */

#endif
