Manual pages: mcmcdiffmceditmcview

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 /*** global variables defined in .c file *********************************************************/
  15 
  16 extern unsigned char conv_displ[256];
  17 extern unsigned char conv_input[256];
  18 
  19 extern const char *cp_display;
  20 extern const char *cp_source;
  21 extern GPtrArray *codepages;
  22 
  23 /*** declarations of public functions ************************************************************/
  24 
  25 const char *get_codepage_id (const int n);
  26 const char *get_codepage_name (const int n);
  27 int get_codepage_index (const char *id);
  28 void load_codepages_list (void);
  29 void free_codepages_list (void);
  30 gboolean is_supported_encoding (const char *encoding);
  31 char *init_translation_table (int cpsource, int cpdisplay);
  32 
  33 /*
  34  * Converter from utf to selected codepage
  35  * param str, utf char
  36  * return char in needle codepage (by global int mc_global.source_codepage)
  37  */
  38 unsigned char convert_from_utf_to_current (const char *str);
  39 
  40 /*
  41  * Converter from utf to selected codepage
  42  * param input_char, gunichar
  43  * return char in needle codepage (by global int mc_global.source_codepage)
  44  */
  45 unsigned char convert_from_utf_to_current_c (int input_char, GIConv conv);
  46 
  47 /*
  48  * Converter from selected codepage 8-bit
  49  * param char input_char, GIConv converter
  50  * return int utf char
  51  */
  52 int convert_from_8bit_to_utf_c (char input_char, GIConv conv);
  53 
  54 /*
  55  * Converter from display codepage 8-bit to utf-8
  56  * param char input_char, GIConv converter
  57  * return int utf char
  58  */
  59 int convert_from_8bit_to_utf_c2 (char input_char);
  60 
  61 GString *str_nconvert_to_input (const char *str, int len);
  62 GString *str_nconvert_to_display (const char *str, int len);
  63 
  64 /* --------------------------------------------------------------------------------------------- */
  65 /*** inline functions ****************************************************************************/
  66 /* --------------------------------------------------------------------------------------------- */
  67 
  68 /* Convert single characters */
  69 static inline int
  70 convert_to_display_c (int c)
     /* [previous][next][first][last][top][bottom][index][help]  */
  71 {
  72     if (c < 0 || c >= 256)
  73         return c;
  74     return (int) conv_displ[c];
  75 }
  76 
  77 /* --------------------------------------------------------------------------------------------- */
  78 
  79 static inline int
  80 convert_from_input_c (int c)
     /* [previous][next][first][last][top][bottom][index][help]  */
  81 {
  82     if (c < 0 || c >= 256)
  83         return c;
  84     return (int) conv_input[c];
  85 }
  86 
  87 /* --------------------------------------------------------------------------------------------- */
  88 
  89 static inline GString *
  90 str_convert_to_input (const char *str)
     /* [previous][next][first][last][top][bottom][index][help]  */
  91 {
  92     return str_nconvert_to_input (str, -1);
  93 }
  94 
  95 /* --------------------------------------------------------------------------------------------- */
  96 
  97 static inline GString *
  98 str_convert_to_display (const char *str)
     /* [previous][next][first][last][top][bottom][index][help]  */
  99 {
 100     return str_nconvert_to_display (str, -1);
 101 }
 102 
 103 /* --------------------------------------------------------------------------------------------- */
 104 
 105 #endif

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