2000-07-04 20:32:37 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-23 00:17:00 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file encoding.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
* \author Jean-Marc Lasgouttes
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
2000-07-04 20:32:37 +00:00
|
|
|
|
|
|
|
|
|
#ifndef ENCODING_H
|
|
|
|
|
#define ENCODING_H
|
|
|
|
|
|
2003-07-26 23:04:39 +00:00
|
|
|
|
#include <map>
|
2003-10-06 15:43:21 +00:00
|
|
|
|
#include <string>
|
|
|
|
|
|
2003-07-26 23:04:39 +00:00
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-07-04 20:32:37 +00:00
|
|
|
|
typedef unsigned short int Uchar;
|
|
|
|
|
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-07-04 20:32:37 +00:00
|
|
|
|
class Encoding {
|
|
|
|
|
public:
|
2000-10-10 12:36:36 +00:00
|
|
|
|
///
|
|
|
|
|
Encoding() {}
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
Encoding(std::string const & n, std::string const & l, Uchar const * e)
|
2000-10-10 12:36:36 +00:00
|
|
|
|
: Name_(n), LatexName_(l) {
|
|
|
|
|
for (int i = 0; i < 256; ++i)
|
|
|
|
|
encoding_table[i] = e[i];
|
|
|
|
|
}
|
|
|
|
|
///
|
2006-04-09 00:26:19 +00:00
|
|
|
|
std::string const & name() const {
|
2000-10-10 12:36:36 +00:00
|
|
|
|
return Name_;
|
|
|
|
|
}
|
|
|
|
|
///
|
2006-04-09 00:26:19 +00:00
|
|
|
|
std::string const & latexName() const {
|
2000-10-10 12:36:36 +00:00
|
|
|
|
return LatexName_;
|
|
|
|
|
}
|
|
|
|
|
///
|
|
|
|
|
Uchar ucs(unsigned char c) const {
|
|
|
|
|
return encoding_table[c];
|
|
|
|
|
}
|
|
|
|
|
private:
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string Name_;
|
2000-10-10 12:36:36 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
std::string LatexName_;
|
2000-10-10 12:36:36 +00:00
|
|
|
|
///
|
|
|
|
|
Uchar encoding_table[256];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extern Encoding symbol_encoding;
|
|
|
|
|
|
|
|
|
|
class Encodings {
|
|
|
|
|
public:
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
typedef std::map<std::string, Encoding> EncodingList;
|
2000-10-10 12:36:36 +00:00
|
|
|
|
///
|
|
|
|
|
Encodings();
|
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
void read(std::string const & filename);
|
2000-10-10 12:36:36 +00:00
|
|
|
|
///
|
2003-10-06 15:43:21 +00:00
|
|
|
|
Encoding const * getEncoding(std::string const & encoding) const;
|
2000-10-10 12:36:36 +00:00
|
|
|
|
///
|
|
|
|
|
Encoding const * symbol_encoding() {
|
|
|
|
|
return &symbol_encoding_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-04 20:32:37 +00:00
|
|
|
|
///
|
|
|
|
|
enum Letter_Form {
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-07-04 20:32:37 +00:00
|
|
|
|
FORM_ISOLATED,
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-07-04 20:32:37 +00:00
|
|
|
|
FORM_FINAL,
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-07-04 20:32:37 +00:00
|
|
|
|
FORM_INITIAL,
|
2000-08-07 20:58:24 +00:00
|
|
|
|
///
|
2000-07-04 20:32:37 +00:00
|
|
|
|
FORM_MEDIAL
|
|
|
|
|
};
|
|
|
|
|
///
|
|
|
|
|
static
|
2006-04-09 00:26:19 +00:00
|
|
|
|
bool isComposeChar_hebrew(unsigned char c);
|
2000-07-04 20:32:37 +00:00
|
|
|
|
///
|
|
|
|
|
static
|
2006-04-09 00:26:19 +00:00
|
|
|
|
bool isComposeChar_arabic(unsigned char c);
|
2000-07-04 20:32:37 +00:00
|
|
|
|
///
|
|
|
|
|
static
|
2002-11-25 21:29:21 +00:00
|
|
|
|
bool is_arabic_special(unsigned char c);
|
|
|
|
|
///
|
|
|
|
|
static
|
2000-07-04 20:32:37 +00:00
|
|
|
|
bool is_arabic(unsigned char c);
|
|
|
|
|
///
|
|
|
|
|
static
|
2006-04-09 00:26:19 +00:00
|
|
|
|
unsigned char transformChar(unsigned char c, Letter_Form form);
|
2000-10-10 12:36:36 +00:00
|
|
|
|
|
2000-07-04 20:32:37 +00:00
|
|
|
|
private:
|
|
|
|
|
///
|
2000-10-10 12:36:36 +00:00
|
|
|
|
EncodingList encodinglist;
|
2000-07-04 20:32:37 +00:00
|
|
|
|
///
|
2000-10-10 12:36:36 +00:00
|
|
|
|
Encoding symbol_encoding_;
|
2000-07-04 20:32:37 +00:00
|
|
|
|
};
|
|
|
|
|
|
2000-10-10 12:36:36 +00:00
|
|
|
|
extern Encodings encodings;
|
2000-07-04 20:32:37 +00:00
|
|
|
|
|
|
|
|
|
#endif
|