]> git.lyx.org Git - lyx.git/blob - src/encoding.h
- Fix sign error in Cursor::setSelection
[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 namespace lyx {
21
22
23 ///
24 typedef unsigned short int Uchar;
25
26 ///
27 class Encoding {
28 public:
29         ///
30         Encoding() {}
31         ///
32         Encoding(std::string const & n, std::string const & l, Uchar const * e)
33                 : Name_(n), LatexName_(l) {
34                 for (int i = 0; i < 256; ++i)
35                         encoding_table[i] = e[i];
36         }
37         ///
38         std::string const & name() const {
39                 return Name_;
40         }
41         ///
42         std::string const & latexName() const {
43                 return LatexName_;
44         }
45         ///
46         Uchar ucs(unsigned char c) const {
47                 return encoding_table[c];
48         }
49 private:
50         ///
51         std::string Name_;
52         ///
53         std::string LatexName_;
54         ///
55         Uchar encoding_table[256];
56 };
57
58 extern Encoding symbol_encoding;
59
60 class Encodings {
61 public:
62         ///
63         typedef std::map<std::string, Encoding> EncodingList;
64         ///
65         Encodings();
66         ///
67         void read(std::string const & filename);
68         ///
69         Encoding const * getEncoding(std::string const & encoding) const;
70         ///
71         Encoding const * symbol_encoding() {
72                 return &symbol_encoding_;
73         }
74
75         ///
76         enum Letter_Form {
77                 ///
78                 FORM_ISOLATED,
79                 ///
80                 FORM_FINAL,
81                 ///
82                 FORM_INITIAL,
83                 ///
84                 FORM_MEDIAL
85         };
86         ///
87         static
88         bool isComposeChar_hebrew(unsigned char c);
89         ///
90         static
91         bool isComposeChar_arabic(unsigned char c);
92         ///
93         static
94         bool is_arabic_special(unsigned char c);
95         ///
96         static
97         bool is_arabic(unsigned char c);
98         ///
99         static
100         unsigned char transformChar(unsigned char c, Letter_Form form);
101
102 private:
103         ///
104         EncodingList encodinglist;
105         ///
106         Encoding symbol_encoding_;
107 };
108
109 extern Encodings encodings;
110
111
112 } // namespace lyx
113
114 #endif