]> git.lyx.org Git - lyx.git/blob - src/Encoding.cpp
c4319ed66bd406e0a6a3f5c904238b2060366d57
[lyx.git] / src / Encoding.cpp
1 /**
2  * \file Encoding.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author Jean-Marc Lasgouttes
8  * \author Dekel Tsur
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #include <config.h>
14
15 #include "Encoding.h"
16
17 #include "LaTeXFeatures.h"
18 #include "Lexer.h"
19 #include "LyXRC.h"
20
21 #include "support/debug.h"
22 #include "support/FileName.h"
23 #include "support/lstrings.h"
24 #include "support/unicode.h"
25
26 #include <boost/cstdint.hpp>
27
28 #include <sstream>
29
30 using namespace std;
31 using namespace lyx::support;
32
33 namespace lyx {
34
35 Encodings encodings;
36
37 namespace {
38
39 char_type arabic_table[172][4] = {
40         {0xfe80, 0xfe80, 0xfe80, 0xfe80}, // 0x0621 = hamza
41         {0xfe81, 0xfe82, 0xfe81, 0xfe82}, // 0x0622 = ligature madda on alef
42         {0xfe83, 0xfe84, 0xfe83, 0xfe84}, // 0x0623 = ligature hamza on alef
43         {0xfe85, 0xfe86, 0xfe85, 0xfe86}, // 0x0624 = ligature hamza on waw
44         {0xfe87, 0xfe88, 0xfe87, 0xfe88}, // 0x0625 = ligature hamza under alef
45         {0xfe89, 0xfe8a, 0xfe8b, 0xfe8c}, // 0x0626 = ligature hamza on ya
46         {0xfe8d, 0xfe8e, 0xfe8d, 0xfe8e}, // 0x0627 = alef
47         {0xfe8f, 0xfe90, 0xfe91, 0xfe92}, // 0x0628 = baa
48         {0xfe93, 0xfe94, 0xfe93, 0xfe94}, // 0x0629 = taa marbuta
49         {0xfe95, 0xfe96, 0xfe97, 0xfe98}, // 0x062a = taa
50         {0xfe99, 0xfe9a, 0xfe9b, 0xfe9c}, // 0x062b = thaa
51         {0xfe9d, 0xfe9e, 0xfe9f, 0xfea0}, // 0x062c = jeem
52         {0xfea1, 0xfea2, 0xfea3, 0xfea4}, // 0x062d = haa
53         {0xfea5, 0xfea6, 0xfea7, 0xfea8}, // 0x062e = khaa
54         {0xfea9, 0xfeaa, 0xfea9, 0xfeaa}, // 0x062f = dal
55
56         {0xfeab, 0xfeac, 0xfeab, 0xfeac}, // 0x0630 = thal
57         {0xfead, 0xfeae, 0xfead, 0xfeae}, // 0x0631 = ra
58         {0xfeaf, 0xfeb0, 0xfeaf, 0xfeb0}, // 0x0632 = zain
59         {0xfeb1, 0xfeb2, 0xfeb3, 0xfeb4}, // 0x0633 = seen
60         {0xfeb5, 0xfeb6, 0xfeb7, 0xfeb8}, // 0x0634 = sheen
61         {0xfeb9, 0xfeba, 0xfebb, 0xfebc}, // 0x0635 = sad
62         {0xfebd, 0xfebe, 0xfebf, 0xfec0}, // 0x0636 = dad
63         {0xfec1, 0xfec2, 0xfec3, 0xfec4}, // 0x0637 = tah
64         {0xfec5, 0xfec6, 0xfec7, 0xfec8}, // 0x0638 = zah
65         {0xfec9, 0xfeca, 0xfecb, 0xfecc}, // 0x0639 = ain
66         {0xfecd, 0xfece, 0xfecf, 0xfed0}, // 0x063a = ghain
67         {0, 0, 0, 0}, // 0x063b
68         {0, 0, 0, 0}, // 0x063c
69         {0, 0, 0, 0}, // 0x063d
70         {0, 0, 0, 0}, // 0x063e
71         {0, 0, 0, 0}, // 0x063f
72
73         {0, 0, 0, 0}, // 0x0640
74         {0xfed1, 0xfed2, 0xfed3, 0xfed4}, // 0x0641 = fa
75         {0xfed5, 0xfed6, 0xfed7, 0xfed8}, // 0x0642 = qaf
76         {0xfed9, 0xfeda, 0xfedb, 0xfedc}, // 0x0643 = kaf
77         {0xfedd, 0xfede, 0xfedf, 0xfee0}, // 0x0644 = lam
78         {0xfee1, 0xfee2, 0xfee3, 0xfee4}, // 0x0645 = meem
79         {0xfee5, 0xfee6, 0xfee7, 0xfee8}, // 0x0646 = noon
80         {0xfee9, 0xfeea, 0xfeeb, 0xfeec}, // 0x0647 = ha
81         {0xfeed, 0xfeee, 0xfeed, 0xfeee}, // 0x0648 = waw
82         {0xfeef, 0xfef0, 0xfeef, 0xfef0}, // 0x0649 = alef maksura
83         {0xfef1, 0xfef2, 0xfef3, 0xfef4}, // 0x064a = ya
84         {0x065b, 0x065b, 0x065b, 0x065b}, // 0x064b = fathatan
85         {0x065c, 0x065c, 0x065c, 0x065c}, // 0x064c = dammatan
86         {0x064d, 0x064d, 0x064d, 0x064d}, // 0x064d = kasratan
87         {0x064e, 0x064e, 0x064e, 0x064e}, // 0x064e = fatha
88         {0x064f, 0x064f, 0x064f, 0x064f}, // 0x064f = damma
89
90         {0x0650, 0x0650, 0x0650, 0x0650}, // 0x0650 = kasra
91         {0x0651, 0x0651, 0x0651, 0x0651}, // 0x0651 = shadda
92         {0x0652, 0x0652, 0x0652, 0x0652}, // 0x0652 = sukun
93
94         {0, 0, 0, 0}, // 0x0653
95         {0, 0, 0, 0}, // 0x0654
96         {0, 0, 0, 0}, // 0x0655
97         {0, 0, 0, 0}, // 0x0656
98         {0, 0, 0, 0}, // 0x0657
99         {0, 0, 0, 0}, // 0x0658
100         {0, 0, 0, 0}, // 0x0659
101         {0, 0, 0, 0}, // 0x065a
102         {0, 0, 0, 0}, // 0x065b
103         {0, 0, 0, 0}, // 0x065c
104         {0, 0, 0, 0}, // 0x065d
105         {0, 0, 0, 0}, // 0x065e
106         {0, 0, 0, 0}, // 0x065f
107         {0, 0, 0, 0}, // 0x0660
108         {0, 0, 0, 0}, // 0x0661
109         {0, 0, 0, 0}, // 0x0662
110         {0, 0, 0, 0}, // 0x0663
111         {0, 0, 0, 0}, // 0x0664
112         {0, 0, 0, 0}, // 0x0665
113         {0, 0, 0, 0}, // 0x0666
114         {0, 0, 0, 0}, // 0x0667
115         {0, 0, 0, 0}, // 0x0668
116         {0, 0, 0, 0}, // 0x0669
117         {0, 0, 0, 0}, // 0x066a
118         {0, 0, 0, 0}, // 0x066b
119         {0, 0, 0, 0}, // 0x066c
120         {0, 0, 0, 0}, // 0x066d
121         {0, 0, 0, 0}, // 0x066e
122         {0, 0, 0, 0}, // 0x066f
123         {0, 0, 0, 0}, // 0x0670
124         {0, 0, 0, 0}, // 0x0671
125         {0, 0, 0, 0}, // 0x0672
126         {0, 0, 0, 0}, // 0x0673
127         {0, 0, 0, 0}, // 0x0674
128         {0, 0, 0, 0}, // 0x0675
129         {0, 0, 0, 0}, // 0x0676
130         {0, 0, 0, 0}, // 0x0677
131         {0, 0, 0, 0}, // 0x0678
132         {0, 0, 0, 0}, // 0x0679
133         {0, 0, 0, 0}, // 0x067a
134         {0, 0, 0, 0}, // 0x067b
135         {0, 0, 0, 0}, // 0x067c
136         {0, 0, 0, 0}, // 0x067d
137         {0xfb56, 0xfb57, 0xfb58, 0xfb59}, // 0x067e = peh 
138         {0, 0, 0, 0}, // 0x067f
139         {0, 0, 0, 0}, // 0x0680
140         {0, 0, 0, 0}, // 0x0681
141         {0, 0, 0, 0}, // 0x0682
142         {0, 0, 0, 0}, // 0x0683
143         {0, 0, 0, 0}, // 0x0684
144         {0, 0, 0, 0}, // 0x0685
145         {0xfb7a, 0xfb7b, 0xfb7c, 0xfb7d}, // 0x0686 = tcheh 
146         {0, 0, 0, 0}, // 0x0687
147         {0, 0, 0, 0}, // 0x0688
148         {0, 0, 0, 0}, // 0x0689
149         {0, 0, 0, 0}, // 0x068a
150         {0, 0, 0, 0}, // 0x068b
151         {0, 0, 0, 0}, // 0x068c
152         {0, 0, 0, 0}, // 0x068d
153         {0, 0, 0, 0}, // 0x068e
154         {0, 0, 0, 0}, // 0x068f
155         {0, 0, 0, 0}, // 0x0690
156         {0, 0, 0, 0}, // 0x0691
157         {0, 0, 0, 0}, // 0x0692
158         {0, 0, 0, 0}, // 0x0693
159         {0, 0, 0, 0}, // 0x0694
160         {0, 0, 0, 0}, // 0x0695
161         {0, 0, 0, 0}, // 0x0696
162         {0, 0, 0, 0}, // 0x0697
163         {0xfb8a, 0xfb8b, 0xfb8a, 0xfb8b}, // 0x0698 = jeh
164         {0, 0, 0, 0}, // 0x0699
165         {0, 0, 0, 0}, // 0x069a
166         {0, 0, 0, 0}, // 0x069b
167         {0, 0, 0, 0}, // 0x069c
168         {0, 0, 0, 0}, // 0x069d
169         {0, 0, 0, 0}, // 0x069e
170         {0, 0, 0, 0}, // 0x069f
171         {0, 0, 0, 0}, // 0x06a0
172         {0, 0, 0, 0}, // 0x06a1
173         {0, 0, 0, 0}, // 0x06a2
174         {0, 0, 0, 0}, // 0x06a3
175         {0, 0, 0, 0}, // 0x06a4
176         {0, 0, 0, 0}, // 0x06a5
177         {0, 0, 0, 0}, // 0x06a6
178         {0, 0, 0, 0}, // 0x06a7
179         {0, 0, 0, 0}, // 0x06a8
180         {0xfb8e, 0xfb8f, 0xfb90, 0xfb91}, // 0x06a9 = farsi kaf 
181         {0, 0, 0, 0}, // 0x06aa
182         {0, 0, 0, 0}, // 0x06ab
183         {0, 0, 0, 0}, // 0x06ac
184         {0, 0, 0, 0}, // 0x06ad
185         {0, 0, 0, 0}, // 0x06ae
186         {0xfb92, 0xfb93, 0xfb94, 0xfb95}, // 0x06af = gaf 
187         {0, 0, 0, 0}, // 0x06b0
188         {0, 0, 0, 0}, // 0x06b1
189         {0, 0, 0, 0}, // 0x06b2
190         {0, 0, 0, 0}, // 0x06b3
191         {0, 0, 0, 0}, // 0x06b4
192         {0, 0, 0, 0}, // 0x06b5
193         {0, 0, 0, 0}, // 0x06b6
194         {0, 0, 0, 0}, // 0x06b7
195         {0, 0, 0, 0}, // 0x06b8
196         {0, 0, 0, 0}, // 0x06b9
197         {0, 0, 0, 0}, // 0x06ba
198         {0, 0, 0, 0}, // 0x06bb
199         {0, 0, 0, 0}, // 0x06bc
200         {0, 0, 0, 0}, // 0x06bd
201         {0, 0, 0, 0}, // 0x06be
202         {0, 0, 0, 0}, // 0x06bf
203         {0, 0, 0, 0}, // 0x06c0
204         {0, 0, 0, 0}, // 0x06c1
205         {0, 0, 0, 0}, // 0x06c2
206         {0, 0, 0, 0}, // 0x06c3
207         {0, 0, 0, 0}, // 0x06c4
208         {0, 0, 0, 0}, // 0x06c5
209         {0, 0, 0, 0}, // 0x06c6
210         {0, 0, 0, 0}, // 0x06c7
211         {0, 0, 0, 0}, // 0x06c8
212         {0, 0, 0, 0}, // 0x06c9
213         {0, 0, 0, 0}, // 0x06ca
214         {0, 0, 0, 0}, // 0x06cb
215         {0xfbfc, 0xfbfd, 0xfbfe, 0xfbff} // 0x06cc = farsi yeh  
216 };
217
218
219 char_type const arabic_start = 0x0621;
220 char_type const arabic_end = 0x06cc;
221
222
223 /// Information about a single UCS4 character
224 struct CharInfo {
225         /// LaTeX command for this character
226         docstring command;
227         /// Needed LaTeX preamble (or feature)
228         string preamble;
229         /// Is this a combining character?
230         bool combining;
231         /// Is \c preamble a feature known by LaTeXFeatures, or a raw LaTeX
232         /// command?
233         bool feature;
234         /// Always force the LaTeX command, even if the encoding contains
235         /// this character?
236         bool force;
237 };
238
239
240 typedef map<char_type, CharInfo> CharInfoMap;
241 CharInfoMap unicodesymbols;
242
243
244 /// The highest code point in UCS4 encoding (1<<20 + 1<<16)
245 char_type const max_ucs4 = 0x110000;
246
247 } // namespace anon
248
249
250 EncodingException::EncodingException(char_type c)
251         : failed_char(c), par_id(0), pos(0)
252 {
253 }
254
255
256 const char * EncodingException::what() const throw()
257 {
258         return "Could not find LaTeX command for a character";
259 }
260
261
262 Encoding::Encoding(string const & n, string const & l, string const & i,
263                    bool f, Encoding::Package p)
264         : Name_(n), LatexName_(l), iconvName_(i), fixedwidth_(f), package_(p)
265 {
266         if (n == "ascii") {
267                 // ASCII can encode 128 code points and nothing else
268                 start_encodable_ = 128;
269                 complete_ = true;
270         } else if (i == "UTF-8") {
271                 // UTF8 can encode all UCS4 code points
272                 start_encodable_ = max_ucs4;
273                 complete_ = true;
274         } else {
275                 complete_ = false;
276         }
277 }
278
279
280 void Encoding::init() const
281 {
282         start_encodable_ = 0;
283         // temporarily switch off lyxerr, since we will generate iconv errors
284         lyxerr.disable();
285         if (fixedwidth_) {
286                 // We do not need to check all UCS4 code points, it is enough
287                 // if we check all 256 code points of this encoding.
288                 for (unsigned short j = 0; j < 256; ++j) {
289                         char const c = char(j);
290                         vector<char_type> const ucs4 = eightbit_to_ucs4(&c, 1, iconvName_);
291                         if (ucs4.size() == 1) {
292                                 char_type const c = ucs4[0];
293                                 CharInfoMap::const_iterator const it = unicodesymbols.find(c);
294                                 if (it == unicodesymbols.end() || !it->second.force)
295                                         encodable_.insert(c);
296                         }
297                 }
298         } else {
299                 // We do not know how many code points this encoding has, and
300                 // they do not have a direct representation as a single byte,
301                 // therefore we need to check all UCS4 code points.
302                 // This is expensive!
303                 for (char_type c = 0; c < max_ucs4; ++c) {
304                         vector<char> const eightbit = ucs4_to_eightbit(&c, 1, iconvName_);
305                         if (!eightbit.empty()) {
306                                 CharInfoMap::const_iterator const it = unicodesymbols.find(c);
307                                 if (it == unicodesymbols.end() || !it->second.force)
308                                         encodable_.insert(c);
309                         }
310                 }
311         }
312         lyxerr.enable();
313         CharSet::iterator it = encodable_.find(start_encodable_);
314         while (it != encodable_.end()) {
315                 encodable_.erase(it);
316                 ++start_encodable_;
317                 it = encodable_.find(start_encodable_);
318         }
319         complete_ = true;
320 }
321
322
323 docstring const Encoding::latexChar(char_type c) const
324 {
325         // assure the used encoding is properly initialized
326         if (!complete_)
327                 init();
328         BOOST_ASSERT(complete_);
329
330         if (c < start_encodable_)
331                 return docstring(1, c);
332         if (encodable_.find(c) == encodable_.end()) {
333                 // c cannot be encoded in this encoding
334                 CharInfoMap::const_iterator const it = unicodesymbols.find(c);
335                 if (it == unicodesymbols.end())
336                         throw EncodingException(c);
337                 else
338                         return it->second.command;
339         }
340         return docstring(1, c);
341 }
342
343
344 set<char_type> Encoding::getSymbolsList() const
345 {
346         // assure the used encoding is properly initialized
347         if (!complete_)
348                 init();
349         BOOST_ASSERT(complete_);
350
351         // first all encodable characters
352         CharSet symbols = encodable_;
353         // add those below start_encodable_
354         for (char_type c = 0; c < start_encodable_; ++c)
355                 symbols.insert(c);
356         // now the ones from the unicodesymbols file
357         CharInfoMap::const_iterator const end = unicodesymbols.end();
358         for (CharInfoMap::const_iterator it = unicodesymbols.begin(); it != end; ++it) {
359                 symbols.insert(it->first);
360         }
361         return symbols;
362 }
363
364
365 void Encodings::validate(char_type c, LaTeXFeatures & features)
366 {
367         CharInfoMap::const_iterator const it = unicodesymbols.find(c);
368         if (it != unicodesymbols.end() && !it->second.preamble.empty()) {
369                 if (it->second.feature)
370                         features.require(it->second.preamble);
371                 else
372                         features.addPreambleSnippet(it->second.preamble);
373         }
374 }
375
376
377 bool Encodings::isComposeChar_hebrew(char_type c)
378 {
379         return c <= 0x05c2 && c >= 0x05b0 &&
380                c != 0x05be && c != 0x05c0;
381 }
382
383
384 // Special Arabic letters are ones that do not get connected from left
385 // they are hamza, alef_madda, alef_hamza, waw_hamza, alef_hamza_under,
386 // alef, tah_marbota, dal, thal, rah, zai, wow, alef_maksoura
387
388 bool Encodings::is_arabic_special(char_type c)
389 {
390         return (c >= 0x0621 && c <= 0x0625) ||
391                 c == 0x0627 || c == 0x0629  ||
392                 c == 0x062f || c == 0x0648  ||
393                (c >= 0x0630 && c <= 0x0632) ||
394                 c == 0x0649 || c == 0x0698;
395 }
396
397
398 bool Encodings::isComposeChar_arabic(char_type c)
399 {
400         return c >= 0x064b && c <= 0x0652;
401 }
402
403
404 bool Encodings::is_arabic(char_type c)
405 {
406         return c >= arabic_start && c <= arabic_end &&
407                arabic_table[c-arabic_start][0];
408 }
409
410
411 char_type Encodings::transformChar(char_type c,
412                                       Encodings::Letter_Form form)
413 {
414         if (!is_arabic(c))
415                 return c;
416
417         return arabic_table[c-arabic_start][form];
418 }
419
420
421 bool Encodings::isCombiningChar(char_type c)
422 {
423         CharInfoMap::const_iterator const it = unicodesymbols.find(c);
424         if (it != unicodesymbols.end())
425                 return it->second.combining;
426         return false;
427 }
428
429
430 bool Encodings::isKnownScriptChar(char_type const c, string & preamble)
431 {
432         CharInfoMap::const_iterator const it = unicodesymbols.find(c);
433
434         if (it == unicodesymbols.end())
435                 return false;
436
437         if (it->second.preamble != "textgreek" &&
438             it->second.preamble != "textcyr")
439                 return false;
440
441         if (preamble.empty()) {
442                 preamble = it->second.preamble;
443                 return true;
444         }
445         return it->second.preamble == preamble;
446 }
447
448
449 Encoding const * Encodings::getFromLyXName(string const & name) const
450 {
451         EncodingList::const_iterator it = encodinglist.find(name);
452         if (it != encodinglist.end())
453                 return &it->second;
454         else
455                 return 0;
456 }
457
458
459 Encoding const * Encodings::getFromLaTeXName(string const & name) const
460 {
461         // We don't use find_if because it makes copies of the pairs in
462         // the map.
463         // This linear search is OK since we don't have many encodings.
464         // Users could even optimize it by putting the encodings they use
465         // most at the top of lib/encodings.
466         EncodingList::const_iterator const end = encodinglist.end();
467         for (EncodingList::const_iterator it = encodinglist.begin(); it != end; ++it)
468                 if (it->second.latexName() == name)
469                         return &it->second;
470         return 0;
471 }
472
473
474 Encodings::Encodings()
475 {
476 }
477
478
479 void Encodings::read(FileName const & encfile, FileName const & symbolsfile)
480 {
481         // We must read the symbolsfile first, because the Encoding
482         // constructor depends on it.
483         Lexer symbolslex(0, 0);
484         symbolslex.setFile(symbolsfile);
485         while (symbolslex.isOK()) {
486                 char_type symbol;
487                 CharInfo info;
488                 string flags;
489
490                 if (symbolslex.next(true)) {
491                         istringstream is(symbolslex.getString());
492                         // reading symbol directly does not work if
493                         // char_type == wchar_t.
494                         boost::uint32_t tmp;
495                         if(!(is >> hex >> tmp))
496                                 break;
497                         symbol = tmp;
498                 } else
499                         break;
500                 if (symbolslex.next(true))
501                         info.command = symbolslex.getDocString();
502                 else
503                         break;
504                 if (symbolslex.next(true))
505                         info.preamble = symbolslex.getString();
506                 else
507                         break;
508                 if (symbolslex.next(true))
509                         flags = symbolslex.getString();
510                 else
511                         break;
512
513                 info.combining = false;
514                 info.feature = false;
515                 info.force = false;
516                 while (!flags.empty()) {
517                         string flag;
518                         flags = split(flags, flag, ',');
519                         if (flag == "combining")
520                                 info.combining = true;
521                         else if (flag == "force")
522                                 info.force = true;
523                         else
524                                 lyxerr << "Ignoring unknown flag `" << flag
525                                        << "' for symbol `0x"
526                                        << hex << symbol << dec
527                                        << "'." << endl;
528                 }
529
530                 if (!info.preamble.empty())
531                         info.feature = info.preamble[0] != '\\';
532
533                 LYXERR(Debug::INFO, "Read unicode symbol " << symbol << " '"
534                         << to_utf8(info.command) << "' '" << info.preamble
535                         << "' " << info.combining << ' ' << info.feature);
536                 unicodesymbols[symbol] = info;
537         }
538
539         // Now read the encodings
540         enum Encodingtags {
541                 et_encoding = 1,
542                 et_end,
543                 et_last
544         };
545
546         struct keyword_item encodingtags[et_last - 1] = {
547                 { "encoding", et_encoding },
548                 { "end", et_end }
549         };
550
551         Lexer lex(encodingtags, et_last - 1);
552         lex.setFile(encfile);
553         while (lex.isOK()) {
554                 switch (lex.lex()) {
555                 case et_encoding:
556                 {
557                         lex.next();
558                         string const name = lex.getString();
559                         lex.next();
560                         string const latexname = lex.getString();
561                         lex.next();
562                         string const iconvname = lex.getString();
563                         lex.next();
564                         string const width = lex.getString();
565                         bool fixedwidth = false;
566                         if (width == "fixed")
567                                 fixedwidth = true;
568                         else if (width == "variable")
569                                 fixedwidth = false;
570                         else {
571                                 lex.printError("Encodings::read: "
572                                                "Unknown width: `$$Token'");
573                         }
574                         
575                         lex.next();
576                         string const p = lex.getString();
577                         Encoding::Package package = Encoding::none;
578                         if (p == "none")
579                                 package = Encoding::none;
580                         else if (p == "inputenc")
581                                 package = Encoding::inputenc;
582                         else if (p == "CJK")
583                                 package = Encoding::CJK;
584                         else {
585                                 lex.printError("Encodings::read: "
586                                                "Unknown package: `$$Token'");
587                         }
588                         
589                         LYXERR(Debug::INFO, "Reading encoding " << name);
590                         encodinglist[name] = Encoding(name, latexname,
591                                                       iconvname, fixedwidth,
592                                                       package);
593                         if (lex.lex() != et_end)
594                                 lex.printError("Encodings::read: "
595                                                "missing end");
596                         break;
597                 }
598                 case et_end:
599                         lex.printError("Encodings::read: Misplaced end");
600                         break;
601                 case Lexer::LEX_FEOF:
602                         break;
603                 default:
604                         lex.printError("Encodings::read: "
605                                        "Unknown tag: `$$Token'");
606                         break;
607                 }
608         }
609 }
610
611
612 } // namespace lyx