4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
10 * Full author contact details are available in file CREDITS.
16 #include "support/docstring.h"
23 namespace support { class FileName; }
31 /// Which LaTeX package handles this encoding?
40 Encoding(std::string const & n, std::string const & l,
41 std::string const & i, bool f, Package p);
45 std::string const & name() const { return Name_; }
47 std::string const & latexName() const { return LatexName_; }
49 std::string const & iconvName() const { return iconvName_; }
51 * Convert \p c to something that LaTeX can understand.
52 * This is either the character itself (if it is representable
53 * in this encoding), or a LaTeX macro.
54 * If the character is not representable in this encoding, but no
55 * LaTeX macro is known, a warning is given of lyxerr, and the
56 * character is returned.
58 docstring const latexChar(char_type c) const;
59 /// Which LaTeX package handles this encoding?
60 Package package() const { return package_; }
65 std::string LatexName_;
67 std::string iconvName_;
68 /// Is this a fixed width encoding?
71 typedef std::set<char_type> CharSet;
72 /// Set of UCS4 characters that we can encode (for singlebyte
74 mutable CharSet encodable_;
75 /// All code points below this are encodable. This helps us to avoid
76 /// lokup of ASCII characters in encodable_ and gives about 1 sec
77 /// speedup on export of the Userguide.
78 mutable char_type start_encodable_;
79 /// Which LaTeX package handles this encoding?
82 * If this is true the stored information about the encoding covers
83 * all encodable characters. We set this to false initially so that
84 * we only need to query iconv for the actually used encodings.
85 * This is needed especially for the multibyte encodings, if we
86 * complete all encoding info on startup it takes 2-3 minutes.
88 mutable bool complete_;
94 typedef std::map<std::string, Encoding> EncodingList;
95 /// iterator to iterate over all encodings.
96 /// We hide the fact that our encoding list is implemented as a map.
97 class const_iterator : public EncodingList::const_iterator {
98 typedef EncodingList::const_iterator base;
100 const_iterator() : base() {}
101 const_iterator(base const & b) : base(b) {}
102 Encoding const & operator*() const { return base::operator*().second; }
103 Encoding const * operator->() const { return &(base::operator*().second); }
107 /// Read the encodings.
108 /// \param encfile encodings definition file
109 /// \param symbolsfile unicode->LaTeX mapping file
110 void read(support::FileName const & encfile,
111 support::FileName const & symbolsfile);
112 /// Get encoding from LyX name \p name
113 Encoding const * getFromLyXName(std::string const & name) const;
114 /// Get encoding from LaTeX name \p name
115 Encoding const * getFromLaTeXName(std::string const & name) const;
118 const_iterator begin() const { return encodinglist.begin(); }
120 const_iterator end() const { return encodinglist.end(); }
134 static bool isComposeChar_hebrew(char_type c);
136 static bool isComposeChar_arabic(char_type c);
138 static bool is_arabic_special(char_type c);
140 static bool is_arabic(char_type c);
142 static char_type transformChar(char_type c, Letter_Form form);
143 /// Is this a combining char?
144 static bool isCombiningChar(char_type c);
146 * Add the preamble snippet needed for the output of \p c to
148 * This does not depend on the used encoding, since the inputenc
149 * package only maps the code point \p c to a command, it does not
150 * make this command available.
152 static void validate(char_type c, LaTeXFeatures & features);
156 EncodingList encodinglist;
159 extern Encodings encodings;