-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
- *
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2001 The LyX Team.
+/**
+ * \file encoding.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * ====================================================== */
+ * \author Lars Gullik Bjønnes
+ * \author Jean-Marc Lasgouttes
+ * \author Dekel Tsur
+ *
+ * Full author contact details are available in file CREDITS.
+ */
#include <config.h>
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
#include "encoding.h"
+
#include "debug.h"
+#include "lyxlex.h"
+#include "lyxrc.h"
+
+#ifndef CXX_GLOBAL_CSTD
+using std::strtol;
+#endif
using std::endl;
+using std::string;
+
Encodings encodings;
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff,
-
+
0xffff, 0x03d2, 0x2032, 0x2264, 0x2215, 0x221e, 0xffff, 0x2663,
0x2666, 0x2665, 0x2660, 0x2194, 0x2190, 0x2191, 0x2192, 0x2193,
unsigned char arabic_table2[63][4] = {
{0x41, 0x41, 0x41, 0x41}, // 0xc1 = hamza
- {0x42, 0xa1, 0x42, 0x42}, // 0xc2 = ligature madda on alef
- {0x43, 0xa2, 0x43, 0x43}, // 0xc3 = ligature hamza on alef
- {0x44, 0xa3, 0x44, 0x44}, // 0xc4 = ligature hamza on waw
- {0x45, 0xa4, 0x45, 0x45}, // 0xc5 = ligature hamza under alef
- {0xf9, 0xf9, 0xf8, 0xa0}, // 0xc6 = ligature hamza on ya
- {0x47, 0xa5, 0xa5, 0xa5}, // 0xc7 = alef
+ {0x42, 0xa1, 0x42, 0xa1}, // 0xc2 = ligature madda on alef
+ {0x43, 0xa2, 0x43, 0xa2}, // 0xc3 = ligature hamza on alef
+ {0x44, 0xa3, 0x44, 0xa3}, // 0xc4 = ligature hamza on waw
+ {0x45, 0xa4, 0x45, 0xa4}, // 0xc5 = ligature hamza under alef
+ {0x46, 0xf9, 0xf8, 0xa0}, // 0xc6 = ligature hamza on ya
+ {0x47, 0xa5, 0x47, 0xa5}, // 0xc7 = alef
{0x48, 0xae, 0xac, 0xad}, // 0xc8 = baa
- {0x49, 0xb1, 0xaf, 0xb0}, // 0xc9 = taa marbuta
+ {0x49, 0xb1, 0x49, 0xb1}, // 0xc9 = taa marbuta
{0x4a, 0xb4, 0xb2, 0xb3}, // 0xca = taa
{0x4b, 0xb7, 0xb5, 0xb6}, // 0xcb = thaa
{0x4c, 0xba, 0xb8, 0xb9}, // 0xcc = jeem
{0x4d, 0xbd, 0xbb, 0xbc}, // 0xcd = haa
{0x4e, 0xc0, 0xbe, 0xbf}, // 0xce = khaa
- {0x4f, 0xa6, 0xa6, 0xa6}, // 0xcf = dal
+ {0x4f, 0xa6, 0x4f, 0xa6}, // 0xcf = dal
- {0x50, 0xa7, 0xa7, 0xa7}, // 0xd0 = thal
- {0x51, 0xa8, 0xa8, 0xa8}, // 0xd1 = ra
- {0x52, 0xa9, 0xa9, 0xa9}, // 0xd2 = zain
- {0x53, 0xc3, 0xc1, 0xc2}, // 0xd3 = seen
+ {0x50, 0xa7, 0x50, 0xa7}, // 0xd0 = thal
+ {0x51, 0xa8, 0x51, 0xa8}, // 0xd1 = ra
+ {0x52, 0xa9, 0x52, 0xa9}, // 0xd2 = zain
+ {0x53, 0xc3, 0xc1, 0xc2}, // 0xd3 = seen
{0x54, 0xc6, 0xc4, 0xc5}, // 0xd4 = sheen
- {0x55, 0xc9, 0xc7, 0xc8}, // 0xd5 = sad
- {0x56, 0xcc, 0xca, 0xcb}, // 0xd6 = dad
- {0x57, 0xcf, 0xcd, 0xce}, // 0xd7 = tah
- {0x58, 0xd2, 0xd0, 0xd1}, // 0xd8 = zah
- {0x59, 0xd5, 0xd3, 0xd4}, // 0xd9 = ain
+ {0x55, 0xc9, 0xc7, 0xc8}, // 0xd5 = sad
+ {0x56, 0xcc, 0xca, 0xcb}, // 0xd6 = dad
+ {0x57, 0xcf, 0xcd, 0xce}, // 0xd7 = tah
+ {0x58, 0xd2, 0xd0, 0xd1}, // 0xd8 = zah
+ {0x59, 0xd5, 0xd3, 0xd4}, // 0xd9 = ain
{0x5a, 0xd8, 0xd6, 0xd7}, // 0xda = ghain
{0,0,0,0}, // 0xdb
{0,0,0,0}, // 0xdc
{0,0,0,0}, // 0xde
{0,0,0,0}, // 0xdf
- {0,0,0,0}, // 0xe0
- {0x61, 0xdb, 0xd9, 0xda}, // 0xe1 = fa
- {0x62, 0xde, 0xdc, 0xdd}, // 0xe2 = qaf
- {0x63, 0xe1, 0xdf, 0xe0}, // 0xe3 = kaf
- {0x64, 0xe4, 0xe2, 0xe3}, // 0xe4 = lam
- {0x65, 0xe7, 0xe5, 0xe6}, // 0xe5 = meem
- {0x66, 0xea, 0xe8, 0xe9}, // 0xe6 = noon
- {0x67, 0xed, 0xeb, 0xec}, // 0xe7 = ha
- {0x68, 0xaa, 0xaa, 0xaa}, // 0xe8 = waw
- {0x69, 0xab, 0xab, 0xab}, // 0xe9 = alef maksura
- {0x6a, 0xf0, 0xee, 0xef}, // 0xea = ya
+ {0,0,0,0}, // 0xe0
+ {0x61, 0xdb, 0xd9, 0xda}, // 0xe1 = fa
+ {0x62, 0xde, 0xdc, 0xdd}, // 0xe2 = qaf
+ {0x63, 0xe1, 0xdf, 0xe0}, // 0xe3 = kaf
+ {0x64, 0xe4, 0xe2, 0xe3}, // 0xe4 = lam
+ {0x65, 0xe7, 0xe5, 0xe6}, // 0xe5 = meem
+ {0x66, 0xea, 0xe8, 0xe9}, // 0xe6 = noon
+ {0x67, 0xed, 0xeb, 0xec}, // 0xe7 = ha
+ {0x68, 0xaa, 0x68, 0xaa}, // 0xe8 = waw
+ {0x69, 0xab, 0x69, 0xab}, // 0xe9 = alef maksura
+ {0x6a, 0xf0, 0xee, 0xef}, // 0xea = ya
{0x6b, 0x6b, 0x6b, 0x6b}, // 0xeb = fathatan
{0x6c, 0x6c, 0x6c, 0x6c}, // 0xec = dammatan
{0x6d, 0x6d, 0x6d, 0x6d}, // 0xed = kasratan
} // namespace anon
-bool Encodings::IsComposeChar_hebrew(unsigned char c)
+bool Encodings::isComposeChar_hebrew(unsigned char c)
{
return c <= 0xd2 && c >= 0xc0 &&
c != 0xce && c != 0xd0;
}
-bool Encodings::IsComposeChar_arabic(unsigned char c)
+// Special Arabic letters are ones that do not get connected from left
+// they are hamza, alef_madda, alef_hamza, waw_hamza, alef_hamza_under,
+// alef, tah_marbota, dal, thal, rah, zai, wow, alef_maksoura
+
+bool Encodings::is_arabic_special(unsigned char c)
+{
+ return (c >= 0xc1 && c <= 0xc5) ||
+ c == 0xc7 || c == 0xc9 ||
+ c == 0xcf || c == 0xe8 ||
+ (c >= 0xd0 && c <= 0xd2) ||
+ c == 0xe9;
+}
+
+bool Encodings::isComposeChar_arabic(unsigned char c)
{
return c >= 0xeb && c <= 0xf2;
}
}
-unsigned char Encodings::TransformChar(unsigned char c,
+unsigned char Encodings::transformChar(unsigned char c,
Encodings::Letter_Form form)
{
if (!is_arabic(c))
return c;
- if (lyxrc.font_norm == "iso10646-1")
+ if (lyxrc.font_norm_type == LyXRC::ISO_10646_1)
return arabic_table2[c-arabic_start][form];
else
return arabic_table[c-arabic_start][form >> 1];
Encoding const * Encodings::getEncoding(string const & encoding) const
{
- EncodingList::const_iterator it = encodinglist.find(encoding);
+ EncodingList::const_iterator it = encodinglist.find(encoding);
if (it != encodinglist.end())
return &it->second;
else
Encodings::Encodings()
{
encodinglist["iso8859-1"] = Encoding("iso8859-1", "latin1", tab_iso8859_1);
- symbol_encoding_ =
+ symbol_encoding_ =
#ifdef USE_UNICODE_FOR_SYMBOLS
Encoding("symbol", "", tab_symbol);
#else
LyXLex lex(encodingtags, et_last - 1);
lex.setFile(filename);
- while (lex.IsOK()) {
+ while (lex.isOK()) {
switch (lex.lex()) {
case et_encoding:
{
lex.next();
- string name = lex.GetString();
+ string const name = lex.getString();
lex.next();
- string latexname = lex.GetString();
+ string const latexname = lex.getString();
lyxerr[Debug::INIT] << "Reading encoding " << name << endl;
Uchar table[256];
for (unsigned int i = 0; i < 256; ++i) {
lex.next();
- string tmp = lex.GetString();
+ string const tmp = lex.getString();
table[i] = ::strtol(tmp.c_str(), 0 , 16);
}
encodinglist[name] = Encoding(name, latexname, table);