root/lib/charsets.h

/* [previous][next][first][last][top][bottom][index][help]  */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. convert_to_display_c
  2. convert_from_input_c
  3. str_convert_to_input
  4. str_convert_to_display

   1 /** \file charsets.h
   2  *  \brief Header: Text conversion from one charset to another
   3  */
   4 
   5 #ifndef MC__CHARSETS_H
   6 #define MC__CHARSETS_H
   7 
   8 /*** typedefs(not structures) and defined constants **********************************************/
   9 
  10 /*** enums ***************************************************************************************/
  11 
  12 /*** structures declarations (and typedefs of structures)*****************************************/
  13 
  14 typedef struct
  15 {
  16     char *id;
  17     char *name;
  18 } codepage_desc;
  19 
  20 /*** global variables defined in .c file *********************************************************/
  21 
  22 extern unsigned char conv_displ[256];
  23 extern unsigned char conv_input[256];
  24 
  25 extern const char *cp_display;
  26 extern const char *cp_source;
  27 extern GPtrArray *codepages;
  28 
  29 /*** declarations of public functions ************************************************************/
  30 
  31 const char *get_codepage_id (const int n);
  32 int get_codepage_index (const char *id);
  33 void load_codepages_list (void);
  34 void free_codepages_list (void);
  35 gboolean is_supported_encoding (const char *encoding);
  36 char *init_translation_table (int cpsource, int cpdisplay);
  37 void convert_to_display (char *str);
  38 void convert_from_input (char *str);
  39 void convert_string (unsigned char *str);
  40 
  41 /*
  42  * Converter from utf to selected codepage
  43  * param str, utf char
  44  * return char in needle codepage (by global int mc_global.source_codepage)
  45  */
  46 unsigned char convert_from_utf_to_current (const char *str);
  47 
  48 /*
  49  * Converter from utf to selected codepage
  50  * param input_char, gunichar
  51  * return char in needle codepage (by global int mc_global.source_codepage)
  52  */
  53 unsigned char convert_from_utf_to_current_c (int input_char, GIConv conv);
  54 
  55 /*
  56  * Converter from selected codepage 8-bit
  57  * param char input_char, GIConv converter
  58  * return int utf char
  59  */
  60 int convert_from_8bit_to_utf_c (char input_char, GIConv conv);
  61 
  62 /*
  63  * Converter from display codepage 8-bit to utf-8
  64  * param char input_char, GIConv converter
  65  * return int utf char
  66  */
  67 int convert_from_8bit_to_utf_c2 (char input_char);
  68 
  69 GString *str_nconvert_to_input (const char *str, int len);
  70 GString *str_nconvert_to_display (const char *str, int len);
  71 
  72 /* --------------------------------------------------------------------------------------------- */
  73 /*** inline functions ****************************************************************************/
  74 /* --------------------------------------------------------------------------------------------- */
  75 
  76 /* Convert single characters */
  77 static inline int
  78 convert_to_display_c (int c)
     /* [previous][next][first][last][top][bottom][index][help]  */
  79 {
  80     if (c < 0 || c >= 256)
  81         return c;
  82     return (int) conv_displ[c];
  83 }
  84 
  85 /* --------------------------------------------------------------------------------------------- */
  86 
  87 static inline int
  88 convert_from_input_c (int c)
     /* [previous][next][first][last][top][bottom][index][help]  */
  89 {
  90     if (c < 0 || c >= 256)
  91         return c;
  92     return (int) conv_input[c];
  93 }
  94 
  95 /* --------------------------------------------------------------------------------------------- */
  96 
  97 static inline GString *
  98 str_convert_to_input (const char *str)
     /* [previous][next][first][last][top][bottom][index][help]  */
  99 {
 100     return str_nconvert_to_input (str, -1);
 101 }
 102 
 103 /* --------------------------------------------------------------------------------------------- */
 104 
 105 static inline GString *
 106 str_convert_to_display (const char *str)
     /* [previous][next][first][last][top][bottom][index][help]  */
 107 {
 108     return str_nconvert_to_display (str, -1);
 109 }
 110 
 111 /* --------------------------------------------------------------------------------------------- */
 112 
 113 #endif /* MC__CHARSETS_H */

/* [previous][next][first][last][top][bottom][index][help]  */