]> git.lyx.org Git - lyx.git/blob - src/encoding.h
Fix bug 2115 ("blueline bug")
[lyx.git] / src / encoding.h
1 // -*- C++ -*-
2 /**
3  * \file encoding.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Jean-Marc Lasgouttes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef ENCODING_H
14 #define ENCODING_H
15
16 #include <map>
17 #include <string>
18
19
20 ///
21 typedef unsigned short int Uchar;
22
23 ///
24 class Encoding {
25 public:
26         ///
27         Encoding() {}
28         ///
29         Encoding(std::string const & n, std::string const & l, Uchar const * e)
30                 : Name_(n), LatexName_(l) {
31                 for (int i = 0; i < 256; ++i)
32                         encoding_table[i] = e[i];
33         }
34         ///
35         std::string const & Name() const {
36                 return Name_;
37         }
38         ///
39         std::string const & LatexName() const {
40                 return LatexName_;
41         }
42         ///
43         Uchar ucs(unsigned char c) const {
44                 return encoding_table[c];
45         }
46 private:
47         ///
48         std::string Name_;
49         ///
50         std::string LatexName_;
51         ///
52         Uchar encoding_table[256];
53 };
54
55 extern Encoding symbol_encoding;
56
57 class Encodings {
58 public:
59         ///
60         typedef std::map<std::string, Encoding> EncodingList;
61         ///
62         Encodings();
63         ///
64         void read(std::string const & filename);
65         ///
66         Encoding const * getEncoding(std::string const & encoding) const;
67         ///
68         Encoding const * symbol_encoding() {
69                 return &symbol_encoding_;
70         }
71
72         ///
73         enum Letter_Form {
74                 ///
75                 FORM_ISOLATED,
76                 ///
77                 FORM_FINAL,
78                 ///
79                 FORM_INITIAL,
80                 ///
81                 FORM_MEDIAL
82         };
83         ///
84         static
85         bool IsComposeChar_hebrew(unsigned char c);
86         ///
87         static
88         bool IsComposeChar_arabic(unsigned char c);
89         ///
90         static
91         bool is_arabic_special(unsigned char c);
92         ///
93         static
94         bool is_arabic(unsigned char c);
95         ///
96         static
97         unsigned char TransformChar(unsigned char c, Letter_Form form);
98
99 private:
100         ///
101         EncodingList encodinglist;
102         ///
103         Encoding symbol_encoding_;
104 };
105
106 extern Encodings encodings;
107
108 #endif