[DEV] rework unichar model ...
This commit is contained in:
parent
4b07b05017
commit
5f8b094486
@ -100,6 +100,14 @@ etk::CCout& etk::CCout::operator << (int t)
|
||||
}
|
||||
|
||||
|
||||
etk::CCout& etk::CCout::operator << (const etk::UniChar& t)
|
||||
{
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t.Get());
|
||||
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
|
||||
hex = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
etk::CCout& etk::CCout::operator << (unsigned int t)
|
||||
{
|
||||
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t);
|
||||
|
@ -31,6 +31,7 @@ namespace etk
|
||||
CCout(void);
|
||||
~CCout(void);
|
||||
CCout& operator << (CHex t);
|
||||
CCout& operator << (const etk::UniChar& t);;
|
||||
CCout& operator << (int t);
|
||||
CCout& operator << (unsigned int t);
|
||||
CCout& operator << (long t);
|
||||
|
696
etk/UString.cpp
696
etk/UString.cpp
@ -38,43 +38,289 @@ etk::CCout& etk::operator <<(etk::CCout &os, const etk::UString &obj)
|
||||
return os;
|
||||
}
|
||||
|
||||
etk::UString::~UString(void)
|
||||
{
|
||||
//m_data.Clear();
|
||||
//m_dataUtf8.Clear();
|
||||
}
|
||||
|
||||
|
||||
etk::UString::UString(void)
|
||||
{
|
||||
//TK_INFO("new etk::UString()");
|
||||
m_data.Clear();
|
||||
m_data.PushBack('\0');
|
||||
}
|
||||
|
||||
|
||||
etk::UString::UString(const char* inputData, int32_t len)
|
||||
|
||||
// single element adding
|
||||
etk::UString::UString(const bool _inputData, etk::UString::printMode_te _mode, bool _preset)
|
||||
{
|
||||
m_data.Clear();
|
||||
if (_preset==true) {
|
||||
switch(_mode) {
|
||||
case etk::UString::printModeBinary :
|
||||
m_data.PushBack('0');
|
||||
m_data.PushBack('b');
|
||||
break;
|
||||
case etk::UString::printModeOctal :
|
||||
m_data.PushBack('0');
|
||||
m_data.PushBack('o');
|
||||
break;
|
||||
case etk::UString::printModeDecimal :
|
||||
break;
|
||||
case etk::UString::printModeHexadecimal :
|
||||
m_data.PushBack('0');
|
||||
m_data.PushBack('x');
|
||||
break;
|
||||
default:
|
||||
case etk::UString::printModeString :
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch(_mode) {
|
||||
case etk::UString::printModeBinary :
|
||||
case etk::UString::printModeOctal :
|
||||
case etk::UString::printModeDecimal :
|
||||
case etk::UString::printModeHexadecimal :
|
||||
if (true == _inputData) {
|
||||
m_data.PushBack('1');
|
||||
} else {
|
||||
m_data.PushBack('0');
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case etk::UString::printModeString :
|
||||
if (true == _inputData) {
|
||||
m_data.PushBack('t');
|
||||
m_data.PushBack('r');
|
||||
m_data.PushBack('u');
|
||||
m_data.PushBack('e');
|
||||
} else {
|
||||
m_data.PushBack('f');
|
||||
m_data.PushBack('a');
|
||||
m_data.PushBack('l');
|
||||
m_data.PushBack('s');
|
||||
m_data.PushBack('e');
|
||||
}
|
||||
break;
|
||||
}
|
||||
m_data.PushBack('\0');
|
||||
Set(inputData, len);
|
||||
}
|
||||
|
||||
etk::UString::UString(const etk::UString& _obj)
|
||||
{
|
||||
//etk_INFO("Constructeur de recopie");
|
||||
m_data = _obj.m_data;
|
||||
}
|
||||
|
||||
etk::UString::UString(const uniChar_t _inputData)
|
||||
{
|
||||
m_data.PushBack(_inputData);
|
||||
m_data.PushBack('\0');
|
||||
}
|
||||
|
||||
etk::UString::UString(const float _inputData)
|
||||
{
|
||||
// TODO : Rework this ...
|
||||
char tmpVal[256];
|
||||
// generate the UString :
|
||||
sprintf(tmpVal, "%f", _inputData);
|
||||
// set the internal data :
|
||||
Set(tmpVal);
|
||||
}
|
||||
|
||||
etk::UString::UString(const double _inputData)
|
||||
{
|
||||
// TODO : Rework this ...
|
||||
char tmpVal[256];
|
||||
// generate the UString :
|
||||
sprintf(tmpVal, "%lf", _inputData);
|
||||
// set the internal data :
|
||||
Set(tmpVal);
|
||||
}
|
||||
|
||||
void etk::UString::Set(const int64_t& _inputData, etk::UString::printMode_te _mode, bool _preset)
|
||||
{
|
||||
if (_preset==true && _mode != etk::UString::printModeString) {
|
||||
Set((uint64_t)_inputData, _mode, _preset);
|
||||
return;
|
||||
}
|
||||
int64_t tmpData = _inputData * (int64_t)(-1);
|
||||
if (_inputData < 0) {
|
||||
if (_mode != etk::UString::printModeString) {
|
||||
m_data.PushBack('l');
|
||||
m_data.PushBack('e');
|
||||
m_data.PushBack('s');
|
||||
m_data.PushBack('s');
|
||||
m_data.PushBack(' ');
|
||||
} else {
|
||||
m_data.PushBack('-');
|
||||
}
|
||||
}
|
||||
Set((uint64_t)tmpData, _mode, _preset);
|
||||
}
|
||||
|
||||
void etk::UString::Set(const uint64_t& _inputData, etk::UString::printMode_te _mode, bool _preset)
|
||||
{
|
||||
if (_preset==true) {
|
||||
switch(_mode) {
|
||||
case etk::UString::printModeBinary :
|
||||
m_data.PushBack('0');
|
||||
m_data.PushBack('b');
|
||||
break;
|
||||
case etk::UString::printModeOctal :
|
||||
m_data.PushBack('0');
|
||||
m_data.PushBack('o');
|
||||
break;
|
||||
case etk::UString::printModeDecimal :
|
||||
break;
|
||||
case etk::UString::printModeHexadecimal :
|
||||
m_data.PushBack('0');
|
||||
m_data.PushBack('x');
|
||||
break;
|
||||
default:
|
||||
case etk::UString::printModeString :
|
||||
break;
|
||||
}
|
||||
}
|
||||
bool startDisplay=false;
|
||||
switch(_mode) {
|
||||
case etk::UString::printModeBinary :
|
||||
for(int32_t iii=63; iii>=0; iii--) {
|
||||
if ((_inputData & (1<<iii)) != 0) {
|
||||
m_data.PushBack('1');
|
||||
startDisplay = true;
|
||||
} else {
|
||||
if (true == startDisplay) {
|
||||
m_data.PushBack('0');
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case etk::UString::printModeOctal :
|
||||
// special strt case ...
|
||||
if ((_inputData & 0x80000000000000LL) != 0) {
|
||||
m_data.PushBack('1');
|
||||
startDisplay = true;
|
||||
} else {
|
||||
if (true == startDisplay) {
|
||||
m_data.PushBack('0');
|
||||
}
|
||||
}
|
||||
for(int32_t iii=59; iii>=0; iii-=3) {
|
||||
uint64_t tmpVal = (_inputData & (((uint64_t)7)<<iii)) >> iii;
|
||||
|
||||
if (tmpVal != 0) {
|
||||
startDisplay = true;
|
||||
}
|
||||
if (true == startDisplay) {
|
||||
tmpVal += '0';
|
||||
m_data.PushBack(tmpVal);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case etk::UString::printModeDecimal :
|
||||
{
|
||||
uint64_t tmpVal = _inputData;
|
||||
etk::UString tmpString;
|
||||
while (tmpVal>0) {
|
||||
int32_t val = tmpVal % 10;
|
||||
tmpString.Add(0,(val+'0'));
|
||||
tmpVal /= 10;
|
||||
}
|
||||
if (tmpString.Size() == 0) {
|
||||
m_data.PushBack('0');
|
||||
} else {
|
||||
*this += tmpString;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case etk::UString::printModeHexadecimal :
|
||||
for(int32_t iii=59; iii>=0; iii-=4) {
|
||||
uint64_t tmpVal = (_inputData & (((uint64_t)0xF)<<iii)) >> iii;
|
||||
if (tmpVal != 0) {
|
||||
startDisplay = true;
|
||||
}
|
||||
if (true == startDisplay) {
|
||||
if (tmpVal < 10) {
|
||||
tmpVal += '0';
|
||||
} else {
|
||||
tmpVal += 'A'-10;
|
||||
}
|
||||
m_data.PushBack(tmpVal);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
case etk::UString::printModeString :
|
||||
m_data.PushBack('T');
|
||||
m_data.PushBack('O');
|
||||
m_data.PushBack('D');
|
||||
m_data.PushBack('O');
|
||||
m_data.PushBack('.');
|
||||
m_data.PushBack('.');
|
||||
m_data.PushBack('.');
|
||||
break;
|
||||
}
|
||||
m_data.PushBack('\0');
|
||||
}
|
||||
|
||||
// multiple element add
|
||||
etk::UString::UString(const uniChar_t* _inputData, int32_t len)
|
||||
{
|
||||
Set(_inputData, len);
|
||||
}
|
||||
|
||||
etk::UString::UString(const char* _inputData, int32_t len)
|
||||
{
|
||||
Set(_inputData, len);
|
||||
}
|
||||
|
||||
etk::UString::UString(const etk::Vector<char>& _inputData)
|
||||
{
|
||||
Set(_inputData);
|
||||
}
|
||||
|
||||
etk::UString::UString(const etk::Vector<int8_t>& _inputData)
|
||||
{
|
||||
Set(_inputData);
|
||||
}
|
||||
|
||||
etk::UString::UString(const etk::Vector<uniChar_t>& _inputData)
|
||||
{
|
||||
Set(_inputData);
|
||||
}
|
||||
|
||||
|
||||
etk::UString::UString(const uniChar_t* inputData, int32_t len)
|
||||
void etk::UString::Set(const etk::Vector<char>& _inputData)
|
||||
{
|
||||
m_data.Clear();
|
||||
m_data.PushBack('\0');
|
||||
Set(inputData, len);
|
||||
if (_inputData.Size()==0) {
|
||||
Clear();
|
||||
return;
|
||||
}
|
||||
etk::Vector<uniChar_t> output_Unicode;
|
||||
unicode::convertUtf8ToUnicode(_inputData, output_Unicode);
|
||||
Set(output_Unicode);
|
||||
}
|
||||
/*
|
||||
etk::UString::UString(const uniChar_t inputData)
|
||||
|
||||
void etk::UString::Set(const etk::Vector<int8_t>& _inputData)
|
||||
{
|
||||
m_data.Clear();
|
||||
m_data.PushBack('\0');
|
||||
Set(&inputData, 1);
|
||||
if (_inputData.Size()==0) {
|
||||
Clear();
|
||||
return;
|
||||
}
|
||||
etk::Vector<uniChar_t> output_Unicode;
|
||||
unicode::convertUtf8ToUnicode(_inputData, output_Unicode);
|
||||
Set(output_Unicode);
|
||||
}
|
||||
|
||||
|
||||
void etk::UString::Set(const etk::Vector<uniChar_t>& inputData)
|
||||
{
|
||||
m_data = inputData;
|
||||
if (m_data.Size()>0) {
|
||||
if (m_data[m_data.Size()-1] != '\0') {
|
||||
m_data.PushBack('\0');
|
||||
}
|
||||
} else {
|
||||
m_data.PushBack('\0');
|
||||
}
|
||||
//TK_DEBUG("m_dataLen="<<m_dataLen << " m_dataLenUTF8="<<m_dataLenUTF8 << " description=" << m_data);
|
||||
}
|
||||
*/
|
||||
|
||||
void etk::UString::Set(const char * inputData, int32_t len)
|
||||
{
|
||||
@ -126,149 +372,23 @@ void etk::UString::Set(const uniChar_t * inputData, int32_t len)
|
||||
}
|
||||
|
||||
|
||||
etk::UString::UString(const bool _inputData)
|
||||
{
|
||||
m_data.Clear();
|
||||
if (true == _inputData) {
|
||||
m_data.PushBack('t');
|
||||
m_data.PushBack('r');
|
||||
m_data.PushBack('u');
|
||||
m_data.PushBack('e');
|
||||
} else {
|
||||
m_data.PushBack('f');
|
||||
m_data.PushBack('a');
|
||||
m_data.PushBack('l');
|
||||
m_data.PushBack('s');
|
||||
m_data.PushBack('e');
|
||||
}
|
||||
m_data.PushBack('\0');
|
||||
}
|
||||
|
||||
etk::UString::UString(const char inputData)
|
||||
{
|
||||
m_data.Clear();
|
||||
m_data.PushBack((uint32_t)inputData);
|
||||
m_data.PushBack('\0');
|
||||
}
|
||||
|
||||
|
||||
etk::UString::UString(int inputData, const char* mode)
|
||||
{
|
||||
char tmpVal[256];
|
||||
// generate the UString :
|
||||
sprintf(tmpVal, mode, inputData);
|
||||
// set the internal data :
|
||||
m_data.Clear();
|
||||
m_data.PushBack('\0');
|
||||
Set(tmpVal);
|
||||
}
|
||||
|
||||
|
||||
etk::UString::UString(unsigned int inputData, const char* mode)
|
||||
{
|
||||
char tmpVal[256];
|
||||
// generate the UString :
|
||||
sprintf(tmpVal, mode, inputData);
|
||||
// set the internal data :
|
||||
m_data.Clear();
|
||||
m_data.PushBack('\0');
|
||||
Set(tmpVal);
|
||||
}
|
||||
|
||||
etk::UString::UString(const float inputData)
|
||||
{
|
||||
char tmpVal[256];
|
||||
// generate the UString :
|
||||
sprintf(tmpVal, "%f", inputData);
|
||||
// set the internal data :
|
||||
m_data.Clear();
|
||||
m_data.PushBack('\0');
|
||||
Set(tmpVal);
|
||||
}
|
||||
|
||||
etk::UString::UString(const double inputData)
|
||||
{
|
||||
char tmpVal[256];
|
||||
// generate the UString :
|
||||
sprintf(tmpVal, "%lf", inputData);
|
||||
// set the internal data :
|
||||
m_data.Clear();
|
||||
m_data.PushBack('\0');
|
||||
Set(tmpVal);
|
||||
}
|
||||
|
||||
etk::UString::UString(const etk::UString &etkS)
|
||||
{
|
||||
//etk_INFO("Constructeur de recopie");
|
||||
m_data = etkS.m_data;
|
||||
}
|
||||
|
||||
|
||||
const etk::UString& etk::UString::operator= (const etk::UString &etkS )
|
||||
const etk::UString& etk::UString::operator= (const etk::UString& _obj )
|
||||
{
|
||||
//TK_INFO("OPERATOR de recopie");
|
||||
if( this != &etkS ) {
|
||||
m_data = etkS.m_data;
|
||||
if( this != &_obj ) {
|
||||
m_data = _obj.m_data;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
const etk::UString& etk::UString::operator= (etk::Vector<char> inputData)
|
||||
bool etk::UString::operator> (const etk::UString& _obj) const
|
||||
{
|
||||
etk::Vector<uniChar_t> output_Unicode;
|
||||
unicode::convertUtf8ToUnicode(inputData, output_Unicode);
|
||||
*this = output_Unicode;
|
||||
return *this;
|
||||
}
|
||||
|
||||
const etk::UString& etk::UString::operator= (etk::Vector<int8_t> inputData)
|
||||
{
|
||||
etk::Vector<uniChar_t> output_Unicode;
|
||||
unicode::convertUtf8ToUnicode(inputData, output_Unicode);
|
||||
*this = output_Unicode;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
const etk::UString& etk::UString::operator= (etk::Vector<uniChar_t> inputData)
|
||||
{
|
||||
m_data = inputData;
|
||||
if (m_data.Size()>0) {
|
||||
if (m_data[m_data.Size()-1] != '\0') {
|
||||
m_data.PushBack('\0');
|
||||
}
|
||||
}
|
||||
//TK_DEBUG("m_dataLen="<<m_dataLen << " m_dataLenUTF8="<<m_dataLenUTF8 << " description=" << m_data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
uniChar_t changeOrder(uniChar_t elemA)
|
||||
{
|
||||
if (elemA >= 'A' && elemA <= 'Z') {
|
||||
return (elemA - (uniChar_t)'A')*2 + 'A';
|
||||
}
|
||||
if (elemA >= 'a' && elemA <= 'z') {
|
||||
return (elemA - (uniChar_t)'a')*2 + 'A' + 1;
|
||||
}
|
||||
if (elemA >= ':' && elemA <= '@') {
|
||||
return elemA + 52;
|
||||
}
|
||||
if (elemA >= '[' && elemA <= '`') {
|
||||
return elemA +26;
|
||||
}
|
||||
return elemA;
|
||||
}
|
||||
|
||||
|
||||
bool etk::UString::operator> (const etk::UString& etkS) const
|
||||
{
|
||||
if( this != &etkS ) {
|
||||
for (int32_t iii=0; iii < m_data.Size() && iii < etkS.m_data.Size(); iii++) {
|
||||
//TK_DEBUG(" compare : '" << (char)m_data[iii] << "'>'" << (char)etkS.m_data[iii] << "' ==> " << changeOrder(m_data[iii]) << ">" << changeOrder(etkS.m_data[iii]) << "");
|
||||
uniChar_t elemA = changeOrder(m_data[iii]);
|
||||
uniChar_t elemB = changeOrder(etkS.m_data[iii]);
|
||||
if( this != &_obj ) {
|
||||
for (int32_t iii=0; iii < m_data.Size() && iii < _obj.m_data.Size(); iii++) {
|
||||
//TK_DEBUG(" compare : '" << (char)m_data[iii] << "'>'" << (char)_obj.m_data[iii] << "' ==> " << changeOrder(m_data[iii]) << ">" << changeOrder(_obj.m_data[iii]) << "");
|
||||
uniChar_t elemA = m_data[iii].ChangeOrder();
|
||||
uniChar_t elemB = _obj.m_data[iii].ChangeOrder();
|
||||
if (elemA != elemB) {
|
||||
if (elemA > elemB) {
|
||||
return true;
|
||||
@ -276,19 +396,19 @@ bool etk::UString::operator> (const etk::UString& etkS) const
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (m_data.Size() > etkS.m_data.Size()) {
|
||||
if (m_data.Size() > _obj.m_data.Size()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool etk::UString::operator>= (const etk::UString& etkS) const
|
||||
bool etk::UString::operator>= (const etk::UString& _obj) const
|
||||
{
|
||||
if( this != &etkS ) {
|
||||
for (int32_t iii=0; iii < m_data.Size() && iii < etkS.m_data.Size(); iii++) {
|
||||
uniChar_t elemA = changeOrder(m_data[iii]);
|
||||
uniChar_t elemB = changeOrder(etkS.m_data[iii]);
|
||||
if( this != &_obj ) {
|
||||
for (int32_t iii=0; iii < m_data.Size() && iii < _obj.m_data.Size(); iii++) {
|
||||
uniChar_t elemA = m_data[iii].ChangeOrder();
|
||||
uniChar_t elemB = _obj.m_data[iii].ChangeOrder();
|
||||
if (elemA != elemB) {
|
||||
if (elemA > elemB) {
|
||||
return true;
|
||||
@ -296,19 +416,19 @@ bool etk::UString::operator>= (const etk::UString& etkS) const
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (m_data.Size() >= etkS.m_data.Size()) {
|
||||
if (m_data.Size() >= _obj.m_data.Size()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool etk::UString::operator< (const etk::UString& etkS) const
|
||||
bool etk::UString::operator< (const etk::UString& _obj) const
|
||||
{
|
||||
if( this != &etkS ) {
|
||||
for (int32_t iii=0; iii < m_data.Size() && iii < etkS.m_data.Size(); iii++) {
|
||||
uniChar_t elemA = changeOrder(m_data[iii]);
|
||||
uniChar_t elemB = changeOrder(etkS.m_data[iii]);
|
||||
if( this != &_obj ) {
|
||||
for (int32_t iii=0; iii < m_data.Size() && iii < _obj.m_data.Size(); iii++) {
|
||||
uniChar_t elemA = m_data[iii].ChangeOrder();
|
||||
uniChar_t elemB = _obj.m_data[iii].ChangeOrder();
|
||||
if (elemA != elemB) {
|
||||
if (elemA < elemB) {
|
||||
return true;
|
||||
@ -316,19 +436,19 @@ bool etk::UString::operator< (const etk::UString& etkS) const
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (m_data.Size() < etkS.m_data.Size()) {
|
||||
if (m_data.Size() < _obj.m_data.Size()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool etk::UString::operator<= (const etk::UString& etkS) const
|
||||
bool etk::UString::operator<= (const etk::UString& _obj) const
|
||||
{
|
||||
if( this != &etkS ) {
|
||||
for (int32_t iii=0; iii < m_data.Size() && iii < etkS.m_data.Size(); iii++) {
|
||||
uniChar_t elemA = changeOrder(m_data[iii]);
|
||||
uniChar_t elemB = changeOrder(etkS.m_data[iii]);
|
||||
if( this != &_obj ) {
|
||||
for (int32_t iii=0; iii < m_data.Size() && iii < _obj.m_data.Size(); iii++) {
|
||||
uniChar_t elemA = m_data[iii].ChangeOrder();
|
||||
uniChar_t elemB = _obj.m_data[iii].ChangeOrder();
|
||||
if (elemA != elemB) {
|
||||
if (elemA < elemB) {
|
||||
return true;
|
||||
@ -336,7 +456,7 @@ bool etk::UString::operator<= (const etk::UString& etkS) const
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (m_data.Size() <= etkS.m_data.Size()) {
|
||||
if (m_data.Size() <= _obj.m_data.Size()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -344,16 +464,16 @@ bool etk::UString::operator<= (const etk::UString& etkS) const
|
||||
}
|
||||
|
||||
|
||||
bool etk::UString::operator== (const etk::UString& etkS) const
|
||||
bool etk::UString::operator== (const etk::UString& _obj) const
|
||||
{
|
||||
if( this != &etkS ) {
|
||||
if (etkS.m_data.Size() != m_data.Size()) {
|
||||
//TK_DEBUG(" not the same size : " << etkS.m_data.Size() << "!=" << m_data.Size());
|
||||
if( this != &_obj ) {
|
||||
if (_obj.m_data.Size() != m_data.Size()) {
|
||||
//TK_DEBUG(" not the same size : " << _obj.m_data.Size() << "!=" << m_data.Size());
|
||||
return false;
|
||||
}
|
||||
for (int32_t iii= 0; iii<m_data.Size(); iii++) {
|
||||
//TK_DEBUG(" check : " << etkS.m_data[iii] << "!=" << m_data[iii]);
|
||||
if (etkS.m_data[iii]!= m_data[iii]){
|
||||
//TK_DEBUG(" check : " << _obj.m_data[iii] << "!=" << m_data[iii]);
|
||||
if (_obj.m_data[iii]!= m_data[iii]){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -362,26 +482,16 @@ bool etk::UString::operator== (const etk::UString& etkS) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool etk::UString::CompareNoCase(const etk::UString& etkS) const
|
||||
bool etk::UString::CompareNoCase(const etk::UString& _obj) const
|
||||
{
|
||||
if( this != &etkS ) {
|
||||
if (etkS.m_data.Size() != m_data.Size()) {
|
||||
//TK_DEBUG(" not the same size : " << etkS.m_data.Size() << "!=" << m_data.Size());
|
||||
if( this != &_obj ) {
|
||||
if (_obj.m_data.Size() != m_data.Size()) {
|
||||
//TK_DEBUG(" not the same size : " << _obj.m_data.Size() << "!=" << m_data.Size());
|
||||
return false;
|
||||
}
|
||||
for (int32_t iii= 0; iii<m_data.Size(); iii++) {
|
||||
//TK_DEBUG(" check : " << etkS.m_data[iii] << "!=" << m_data[iii]);
|
||||
uniChar_t in1 = etkS.m_data[iii];
|
||||
uniChar_t in2 = m_data[iii];
|
||||
if( in1>=(uniChar_t)'A'
|
||||
&& in1<=(uniChar_t)'Z') {
|
||||
in1 += (uniChar_t)'a' - (uniChar_t)'A';
|
||||
}
|
||||
if( in2>=(uniChar_t)'A'
|
||||
&& in2<=(uniChar_t)'Z') {
|
||||
in2 += (uniChar_t)'a' - (uniChar_t)'A';
|
||||
}
|
||||
if (in1!=in2){
|
||||
//TK_DEBUG(" check : " << _obj.m_data[iii] << "!=" << m_data[iii]);
|
||||
if (false==m_data[iii].CompareNoCase(_obj.m_data[iii])){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -391,21 +501,21 @@ bool etk::UString::CompareNoCase(const etk::UString& etkS) const
|
||||
}
|
||||
|
||||
|
||||
bool etk::UString::operator!= (const etk::UString& etkS) const
|
||||
bool etk::UString::operator!= (const etk::UString& _obj) const
|
||||
{
|
||||
return !(*this == etkS);
|
||||
return !(*this == _obj);
|
||||
}
|
||||
|
||||
|
||||
const etk::UString& etk::UString::operator+= (const etk::UString &etkS)
|
||||
const etk::UString& etk::UString::operator+= (const etk::UString &_obj)
|
||||
{
|
||||
if (0 < etkS.Size()) {
|
||||
if (0 < _obj.Size()) {
|
||||
// remove the last '\0'
|
||||
m_data.PopBack();
|
||||
// copy the data ...
|
||||
m_data += etkS.m_data;
|
||||
m_data += _obj.m_data;
|
||||
// This previous include the \0 in case of the 2 UString are different...
|
||||
if( this == &etkS ) {
|
||||
if( this == &_obj ) {
|
||||
// add the removed end UString
|
||||
m_data.PushBack('\0');
|
||||
}
|
||||
@ -414,13 +524,11 @@ const etk::UString& etk::UString::operator+= (const etk::UString &etkS)
|
||||
}
|
||||
|
||||
|
||||
etk::UString etk::UString::operator+ (const etk::UString &etkS) const
|
||||
etk::UString etk::UString::operator+ (const etk::UString &_obj) const
|
||||
{
|
||||
etk::UString temp;
|
||||
//TK_INFO(" UString(arg) : \"" << etkS.m_data << "\"");
|
||||
//TK_INFO(" UString(direct) : \"" << m_data << "\"");
|
||||
temp += *this;
|
||||
temp += etkS;
|
||||
temp += _obj;
|
||||
return temp;
|
||||
}
|
||||
|
||||
@ -445,49 +553,49 @@ int32_t etk::UString::Size(void) const
|
||||
}
|
||||
|
||||
|
||||
void etk::UString::Add(int32_t currentID, const char* inputData)
|
||||
void etk::UString::Add(int32_t _currentID, const char* _inputData)
|
||||
{
|
||||
etk::UString tmpString(inputData);
|
||||
Add(currentID, tmpString.pointer() );
|
||||
etk::UString tmpString(_inputData);
|
||||
Add(_currentID, tmpString.pointer() );
|
||||
}
|
||||
|
||||
|
||||
void etk::UString::Add(int32_t currentID, const uniChar_t* inputData)
|
||||
void etk::UString::Add(int32_t _currentID, const uniChar_t* _inputData)
|
||||
{
|
||||
// get the input lenght
|
||||
int32_t len = strlen(inputData);
|
||||
int32_t len = strlen(_inputData);
|
||||
if (0 == len) {
|
||||
TK_WARNING("no data to add on the current UString");
|
||||
return;
|
||||
} else if (currentID < 0) {
|
||||
TK_WARNING("Curent ID(" << currentID << ") < 0 ==> Add at the start");
|
||||
currentID = 0;
|
||||
} else if (currentID > Size() ) {
|
||||
TK_ERROR("Curent ID(" << currentID << ") > maxSize ... (" << Size() << ") ==> add at the end ...");
|
||||
m_data.PushBack(inputData, len);
|
||||
} else if (_currentID < 0) {
|
||||
TK_WARNING("Curent ID(" << _currentID << ") < 0 ==> Add at the start");
|
||||
_currentID = 0;
|
||||
} else if (_currentID > Size() ) {
|
||||
TK_ERROR("Curent ID(" << _currentID << ") > maxSize ... (" << Size() << ") ==> add at the end ...");
|
||||
m_data.PushBack(_inputData, len);
|
||||
return;
|
||||
}
|
||||
m_data.Insert(currentID, inputData, len);
|
||||
m_data.Insert(_currentID, _inputData, len);
|
||||
}
|
||||
|
||||
|
||||
void etk::UString::Add(int32_t currentID, const uniChar_t inputData)
|
||||
void etk::UString::Add(int32_t _currentID, const uniChar_t _inputData)
|
||||
{
|
||||
uniChar_t data[2];
|
||||
data[0] = inputData;
|
||||
data[0] = _inputData;
|
||||
data[1] = 0;
|
||||
Add(currentID, data);
|
||||
Add(_currentID, data);
|
||||
}
|
||||
|
||||
|
||||
void etk::UString::Remove(int32_t currentID, int32_t len)
|
||||
void etk::UString::Remove(int32_t _currentID, int32_t _len)
|
||||
{
|
||||
if (0 >= len) {
|
||||
if (0 >= _len) {
|
||||
TK_ERROR("no data to remove on the current UString");
|
||||
return;
|
||||
}
|
||||
// TODO : check the size of the data
|
||||
m_data.EraseLen(currentID, len);
|
||||
m_data.EraseLen(_currentID, _len);
|
||||
}
|
||||
|
||||
|
||||
@ -497,22 +605,30 @@ void etk::UString::Clear(void)
|
||||
m_data.PushBack('\0');
|
||||
}
|
||||
|
||||
|
||||
int32_t etk::UString::FindForward(const char element, int32_t startPos) const
|
||||
int32_t etk::UString::FindForward(const uniChar_t _element, int32_t _startPos) const
|
||||
{
|
||||
return FindForward((uniChar_t)element, startPos);
|
||||
}
|
||||
|
||||
|
||||
int32_t etk::UString::FindForward(const uniChar_t element, int32_t startPos) const
|
||||
{
|
||||
if (startPos < 0) {
|
||||
startPos = 0;
|
||||
} else if (startPos >= Size() ) {
|
||||
if (_startPos < 0) {
|
||||
_startPos = 0;
|
||||
} else if (_startPos >= Size() ) {
|
||||
return -1;
|
||||
}
|
||||
for (int32_t iii=startPos; iii< Size(); iii++) {
|
||||
if (m_data[iii] == element) {
|
||||
for (int32_t iii=_startPos; iii< Size(); iii++) {
|
||||
if (m_data[iii] == _element) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t etk::UString::FindBack(const uniChar_t _element, int32_t _startPos) const
|
||||
{
|
||||
if (_startPos < 0) {
|
||||
return -1;
|
||||
} else if (_startPos >= Size() ) {
|
||||
_startPos = Size();
|
||||
}
|
||||
for (int32_t iii=_startPos; iii>=0; iii--) {
|
||||
if (m_data[iii] == _element) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
@ -520,42 +636,20 @@ int32_t etk::UString::FindForward(const uniChar_t element, int32_t startPos) con
|
||||
}
|
||||
|
||||
|
||||
int32_t etk::UString::FindBack(const char element, int32_t startPos) const
|
||||
{
|
||||
return FindBack((uniChar_t)element, startPos);
|
||||
}
|
||||
|
||||
|
||||
int32_t etk::UString::FindBack(const uniChar_t element, int32_t startPos) const
|
||||
{
|
||||
if (startPos < 0) {
|
||||
return -1;
|
||||
} else if (startPos >= Size() ) {
|
||||
startPos = Size();
|
||||
}
|
||||
for (int32_t iii=startPos; iii>=0; iii--) {
|
||||
if (m_data[iii] == element) {
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
etk::UString etk::UString::Extract(int32_t posStart, int32_t posEnd) const
|
||||
etk::UString etk::UString::Extract(int32_t _posStart, int32_t _posEnd) const
|
||||
{
|
||||
etk::UString out;
|
||||
if (posStart < 0) {
|
||||
posStart = 0;
|
||||
} else if (posStart >= Size() ) {
|
||||
if (_posStart < 0) {
|
||||
_posStart = 0;
|
||||
} else if (_posStart >= Size() ) {
|
||||
return out;
|
||||
}
|
||||
if (posEnd < 0) {
|
||||
if (_posEnd < 0) {
|
||||
return out;
|
||||
} else if (posEnd >= Size() ) {
|
||||
posEnd = Size();
|
||||
} else if (_posEnd >= Size() ) {
|
||||
_posEnd = Size();
|
||||
}
|
||||
out.m_data = m_data.Extract(posStart, posEnd);
|
||||
out.m_data = m_data.Extract(_posStart, _posEnd);
|
||||
out.m_data.PushBack('\0');
|
||||
return out;
|
||||
}
|
||||
@ -569,34 +663,24 @@ etk::Vector<uniChar_t> etk::UString::GetVector(void)
|
||||
}
|
||||
|
||||
|
||||
bool etk::UString::StartWith(const etk::UString& data, bool caseSensitive) const
|
||||
bool etk::UString::StartWith(const etk::UString& _data, bool _caseSensitive) const
|
||||
{
|
||||
if (data.Size() == 0) {
|
||||
if (_data.Size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (data.Size() > Size()) {
|
||||
if (_data.Size() > Size()) {
|
||||
return false;
|
||||
}
|
||||
if (true == caseSensitive) {
|
||||
for (int32_t iii=0; iii<data.Size(); iii++) {
|
||||
if (data[iii] != m_data[iii]) {
|
||||
if (true == _caseSensitive) {
|
||||
for (int32_t iii=0; iii<_data.Size(); iii++) {
|
||||
if (_data[iii] != m_data[iii]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int32_t iii=0; iii<data.Size(); iii++) {
|
||||
if (data[iii] != m_data[iii]) {
|
||||
uniChar_t in1 = data[iii];
|
||||
uniChar_t in2 = m_data[iii];
|
||||
if (in1 <= (uniChar_t)'Z' && in1 >= (uniChar_t)'A') {
|
||||
in1 = in1 + (uniChar_t)'a' - (uniChar_t)'A';
|
||||
}
|
||||
if (in2 <= 'Z' && in2 >= 'A') {
|
||||
in2 = in2 + (uniChar_t)'a' - (uniChar_t)'A';
|
||||
}
|
||||
if (in1 != in2) {
|
||||
return false;
|
||||
}
|
||||
for (int32_t iii=0; iii<_data.Size(); iii++) {
|
||||
if (false==m_data[iii].CompareNoCase(_data[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -604,38 +688,28 @@ bool etk::UString::StartWith(const etk::UString& data, bool caseSensitive) const
|
||||
}
|
||||
|
||||
|
||||
bool etk::UString::EndWith(const etk::UString& data, bool caseSensitive) const
|
||||
bool etk::UString::EndWith(const etk::UString& _data, bool _caseSensitive) const
|
||||
{
|
||||
if (data.Size() == 0) {
|
||||
if (_data.Size() == 0) {
|
||||
return false;
|
||||
}
|
||||
if (data.Size() > Size()) {
|
||||
if (_data.Size() > Size()) {
|
||||
return false;
|
||||
}
|
||||
if (true == caseSensitive) {
|
||||
for( int32_t iii=Size()-1, jjj=data.Size()-1;
|
||||
if (true == _caseSensitive) {
|
||||
for( int32_t iii=Size()-1, jjj=_data.Size()-1;
|
||||
iii>=0 && jjj>=0;
|
||||
iii--, jjj--) {
|
||||
if (data[jjj] != m_data[iii]) {
|
||||
if (_data[jjj] != m_data[iii]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for( int32_t iii=Size()-1, jjj=data.Size()-1;
|
||||
for( int32_t iii=Size()-1, jjj=_data.Size()-1;
|
||||
iii>=0 && jjj>=0;
|
||||
iii--, jjj--) {
|
||||
if (data[jjj] != m_data[iii]) {
|
||||
uniChar_t in1 = data[jjj];
|
||||
uniChar_t in2 = m_data[iii];
|
||||
if (in1 <= (uniChar_t)'Z' && in1 >= (uniChar_t)'A') {
|
||||
in1 = in1 + (uniChar_t)'a' - (uniChar_t)'A';
|
||||
}
|
||||
if (in2 <= 'Z' && in2 >= 'A') {
|
||||
in2 = in2 + (uniChar_t)'a' - (uniChar_t)'A';
|
||||
}
|
||||
if (in1 != in2) {
|
||||
return false;
|
||||
}
|
||||
if (false==m_data[iii].CompareNoCase(_data[iii])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -675,8 +749,8 @@ int64_t etk::UString::ToInt64(void) const
|
||||
isOdd = true;
|
||||
}
|
||||
} else {
|
||||
if (m_data[iii]>='0' && m_data[iii]<='9') {
|
||||
int32_t val = m_data[iii] - '0';
|
||||
if (true==m_data[iii].IsInteger()) {
|
||||
int32_t val = m_data[iii].ToInt32();
|
||||
ret = ret*10 + val;
|
||||
} else {
|
||||
break;
|
||||
@ -700,8 +774,8 @@ uint64_t etk::UString::ToUInt64(void) const
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (m_data[iii]>='0' && m_data[iii]<='9') {
|
||||
int32_t val = m_data[iii] - '0';
|
||||
if (true==m_data[iii].IsInteger()) {
|
||||
int32_t val = m_data[iii].ToInt32();
|
||||
ret = ret*10 + val;
|
||||
} else {
|
||||
break;
|
||||
@ -763,8 +837,8 @@ double etk::UString::ToDouble(void) const
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (m_data[iii]>='0' && m_data[iii]<='9') {
|
||||
int32_t val = m_data[iii] - '0';
|
||||
if (true==m_data[iii].IsInteger()) {
|
||||
int32_t val = m_data[iii].ToInt32();
|
||||
double val2 = val;
|
||||
if (dotPos>=0) {
|
||||
ret += (val2*(((double)dotPos)*0.1));
|
||||
|
100
etk/UString.h
100
etk/UString.h
@ -18,58 +18,80 @@ namespace etk
|
||||
{
|
||||
class UString
|
||||
{
|
||||
public:
|
||||
typedef enum {
|
||||
printModeBinary,
|
||||
printModeOctal,
|
||||
printModeDecimal,
|
||||
printModeHexadecimal,
|
||||
printModeString,
|
||||
} printMode_te;
|
||||
private :
|
||||
etk::Vector<uniChar_t> m_data; //!< internal data is stored in the Unicode properties ...
|
||||
public:
|
||||
// Constructeurs
|
||||
UString(void);
|
||||
UString(const uniChar_t* inputData, int32_t len = -1);
|
||||
UString(const char* inputData, int32_t len = -1);
|
||||
// destructor :
|
||||
~UString(void) { };
|
||||
// recopy operator :
|
||||
UString(const etk::UString& _obj);
|
||||
|
||||
// single element adding
|
||||
UString(const bool _inputData, printMode_te _mode=printModeString, bool _preset=false);
|
||||
UString(const uniChar_t _inputData);
|
||||
UString(const float _inputData);
|
||||
UString(const double _inputData);
|
||||
UString(const int8_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false) { Set((int64_t)_inputData, _mode, _preset); };
|
||||
UString(const int16_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false) { Set((int64_t)_inputData, _mode, _preset); };
|
||||
UString(const int32_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false) { Set((int64_t)_inputData, _mode, _preset); };
|
||||
UString(const int64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false) { Set(_inputData, _mode, _preset); };
|
||||
UString(const uint8_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false) { Set((uint64_t)_inputData, _mode, _preset); };
|
||||
UString(const uint16_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false) { Set((uint64_t)_inputData, _mode, _preset); };
|
||||
UString(const uint32_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false) { Set((uint64_t)_inputData, _mode, _preset); };
|
||||
UString(const uint64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false) { Set(_inputData, _mode, _preset); };
|
||||
// multiple element add
|
||||
UString(const uniChar_t* _inputData, int32_t len = -1);
|
||||
UString(const char* _inputData, int32_t len = -1);
|
||||
UString(const etk::Vector<char>& inputData);
|
||||
UString(const etk::Vector<int8_t>& inputData);
|
||||
UString(const etk::Vector<uniChar_t>& inputData);
|
||||
// generic setter
|
||||
void Set(const uniChar_t* inputData, int32_t len=-1);
|
||||
void Set(const char* inputData, int32_t len=-1);
|
||||
// basic convertion integer en string
|
||||
UString(const bool _inputData);
|
||||
UString(const char _inputData);
|
||||
UString(int inputData, const char* mode="%d");
|
||||
UString(unsigned int inputData, const char* mode="%d");
|
||||
UString(const float inputData);
|
||||
UString(const double inputData);
|
||||
UString(const etk::UString &etkS);
|
||||
//UString(const uniChar_t inputData);
|
||||
// destructor :
|
||||
~UString(void);
|
||||
void Set(const etk::Vector<char>& inputData);
|
||||
void Set(const etk::Vector<int8_t>& inputData);
|
||||
void Set(const etk::Vector<uniChar_t>& inputData);
|
||||
void Set(const int64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false);
|
||||
void Set(const uint64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false);
|
||||
|
||||
/*****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const etk::UString& operator= (const etk::UString& etkS );
|
||||
const etk::UString& operator= (etk::Vector<char> inputData);
|
||||
const etk::UString& operator= (etk::Vector<int8_t> inputData);
|
||||
const etk::UString& operator= (etk::Vector<uniChar_t> inputData);
|
||||
const etk::UString& operator= (const etk::UString& _obj );
|
||||
/*****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const etk::UString& etkS) const;
|
||||
bool CompareNoCase(const etk::UString& etkS) const;
|
||||
bool operator== (const etk::UString& _obj) const;
|
||||
bool CompareNoCase(const etk::UString& _obj) const;
|
||||
/*****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const etk::UString& etkS) const;
|
||||
bool operator!= (const etk::UString& _obj) const;
|
||||
/*****************************************************
|
||||
* > < >= <= operator
|
||||
*****************************************************/
|
||||
bool operator> (const etk::UString& etkS) const;
|
||||
bool operator>= (const etk::UString& etkS) const;
|
||||
bool operator< (const etk::UString& etkS) const;
|
||||
bool operator<= (const etk::UString& etkS) const;
|
||||
bool operator> (const etk::UString& _obj) const;
|
||||
bool operator>= (const etk::UString& _obj) const;
|
||||
bool operator< (const etk::UString& _obj) const;
|
||||
bool operator<= (const etk::UString& _obj) const;
|
||||
/*****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const etk::UString& operator+= (const etk::UString &etkS);
|
||||
const etk::UString& operator+= (const etk::UString &_obj);
|
||||
/*****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
etk::UString operator+ (const etk::UString &etkS) const;
|
||||
etk::UString operator+ (const etk::UString &_obj) const;
|
||||
/*****************************************************
|
||||
* << operator
|
||||
*****************************************************/
|
||||
@ -85,29 +107,27 @@ namespace etk
|
||||
/*****************************************************
|
||||
* Cout << operator
|
||||
*****************************************************/
|
||||
friend etk::CCout& operator <<( etk::CCout &os,const etk::UString &obj);
|
||||
friend etk::CCout& operator <<( etk::CCout& _os,const etk::UString& _obj);
|
||||
/*****************************************************
|
||||
* [] operator
|
||||
*****************************************************/
|
||||
const uniChar_t& operator[] (int32_t pos) const {
|
||||
return m_data[pos];
|
||||
const uniChar_t& operator[] (int32_t _pos) const {
|
||||
return m_data[_pos];
|
||||
}
|
||||
uniChar_t& operator[] (int32_t pos) {
|
||||
return m_data[pos];
|
||||
uniChar_t& operator[] (int32_t _pos) {
|
||||
return m_data[_pos];
|
||||
}
|
||||
|
||||
/*****************************************************
|
||||
* toolbox
|
||||
*****************************************************/
|
||||
// Start With ...
|
||||
bool StartWith(const etk::UString& data, bool caseSensitive=true) const ;
|
||||
bool StartWith(const etk::UString& _data, bool _caseSensitive=true) const ;
|
||||
// End With ...
|
||||
bool EndWith(const etk::UString& data, bool caseSensitive=true) const ;
|
||||
bool EndWith(const etk::UString& _data, bool _caseSensitive=true) const ;
|
||||
// Find element
|
||||
int32_t FindForward(const char data, int32_t startPos=0) const;
|
||||
int32_t FindForward(const uniChar_t data, int32_t startPos=0) const;
|
||||
int32_t FindBack(const char data, int32_t startPos=0x7FFFFFFF) const;
|
||||
int32_t FindBack(const uniChar_t data, int32_t startPos=0x7FFFFFFF) const;
|
||||
int32_t FindForward(const uniChar_t _data, int32_t _startPos=0) const;
|
||||
int32_t FindBack(const uniChar_t _data, int32_t _startPos=0x7FFFFFFF) const;
|
||||
|
||||
bool IsEmpty(void) const;
|
||||
int32_t Size(void) const;
|
||||
@ -126,6 +146,12 @@ namespace etk
|
||||
|
||||
etk::Char c_str(void) const;
|
||||
|
||||
void Lower(void);
|
||||
etk::UString ToLower(void);
|
||||
void Upper(void);
|
||||
etk::UString ToUpper(void);
|
||||
|
||||
|
||||
// Sting operation :
|
||||
etk::UString Extract(int32_t posStart=0, int32_t posEnd=0x7FFFFFFF) const;
|
||||
/**
|
||||
|
192
etk/UniChar.cpp
Normal file
192
etk/UniChar.cpp
Normal file
@ -0,0 +1,192 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <etk/UniChar.h>
|
||||
#include <etk/unicode.h>
|
||||
|
||||
#include <etk/DebugInternal.h>
|
||||
#include <etk/Stream.h>
|
||||
#include <etk/Vector.h>
|
||||
#include <etk/Char.h>
|
||||
|
||||
void etk::UniChar::Lower(void)
|
||||
{
|
||||
if( m_value>=(uint32_t)'A'
|
||||
&& m_value<=(uint32_t)'Z') {
|
||||
m_value += (uint32_t)'a' - (uint32_t)'A';
|
||||
}
|
||||
}
|
||||
|
||||
etk::UniChar etk::UniChar::ToLower(void) const
|
||||
{
|
||||
if( m_value>=(uint32_t)'A'
|
||||
&& m_value<=(uint32_t)'Z') {
|
||||
return m_value + (uint32_t)'a' - (uint32_t)'A';
|
||||
}
|
||||
return m_value;
|
||||
}
|
||||
|
||||
void etk::UniChar::Upper(void)
|
||||
{
|
||||
if( m_value>=(uint32_t)'a'
|
||||
&& m_value<=(uint32_t)'z') {
|
||||
m_value += (uint32_t)'A' - (uint32_t)'a';
|
||||
}
|
||||
}
|
||||
|
||||
etk::UniChar etk::UniChar::ToUpper(void) const
|
||||
{
|
||||
if( m_value>=(uint32_t)'a'
|
||||
&& m_value<=(uint32_t)'z') {
|
||||
return m_value + (uint32_t)'A' - (uint32_t)'a';
|
||||
}
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool etk::UniChar::CompareNoCase(const etk::UniChar& _obj) const
|
||||
{
|
||||
return ToUpper() == _obj.ToUpper();
|
||||
}
|
||||
|
||||
|
||||
etk::UniChar etk::UniChar::ChangeOrder(void) const
|
||||
{
|
||||
if (m_value >= 'A' && m_value <= 'Z') {
|
||||
return (m_value - (uint32_t)'A')*2 + 'A';
|
||||
}
|
||||
if (m_value >= 'a' && m_value <= 'z') {
|
||||
return (m_value - (uint32_t)'a')*2 + 'A' + 1;
|
||||
}
|
||||
if (m_value >= ':' && m_value <= '@') {
|
||||
return m_value + 52;
|
||||
}
|
||||
if (m_value >= '[' && m_value <= '`') {
|
||||
return m_value +26;
|
||||
}
|
||||
return m_value;
|
||||
}
|
||||
|
||||
|
||||
bool etk::UniChar::IsInteger(void) const
|
||||
{
|
||||
if( m_value>=(uint32_t)'0'
|
||||
&& m_value<=(uint32_t)'9') {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int32_t etk::UniChar::ToInt32(void) const
|
||||
{
|
||||
return m_value - (uint32_t)'0';
|
||||
}
|
||||
/*
|
||||
etk::CCout& etk::operator <<(etk::CCout& _os, const etk::UniChar& _obj)
|
||||
{
|
||||
char output_UTF8[8];
|
||||
unicode::convertUnicodeToUtf8(_obj, output_UTF8);
|
||||
_os << &output_UTF8[0];
|
||||
return _os;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
uint32_t etk::UniChar::GetUtf8(void) const
|
||||
{
|
||||
uint32_t output = 0;
|
||||
if (m_value <= 127) {
|
||||
output = m_value;
|
||||
} else if (m_value <= 2047) {
|
||||
// output ==> 00000000 00000000 110xxxxx 10xxxxxx
|
||||
// input ==> -------- -------- -----222 22111111
|
||||
output = 0x0000C080;
|
||||
output+= (m_value & 0x000007C0)<<2;
|
||||
output+= m_value & 0x0000003F;
|
||||
} else if (m_value <= 65535) {
|
||||
// output ==> 00000000 1110xxxx 10xxxxxx 10xxxxxx
|
||||
// input ==> -------- -------- 33332222 22111111
|
||||
output = 0x00E08080;
|
||||
output+= (m_value & 0x0000F000)<<4;
|
||||
output+= (m_value & 0x00000FC0)<<2;
|
||||
output+= m_value & 0x0000003F;
|
||||
} else if (m_value <= 1114111) {
|
||||
// output ==> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
// input ==> -------- ---44433 33332222 22111111
|
||||
output = 0xF0808080;
|
||||
output+= (m_value & 0x001C0000)<<6;
|
||||
output+= (m_value & 0x0003F000)<<4;
|
||||
output+= (m_value & 0x00000FC0)<<2;
|
||||
output+= m_value & 0x0000003F;
|
||||
} else {
|
||||
TK_ERROR("NON UTF8 caracter input...");
|
||||
return 0;
|
||||
}
|
||||
//printf("utf8convertion : %d=%08x ==> %08x\n",value, value, output);
|
||||
return output;
|
||||
}
|
||||
|
||||
int8_t etk::UniChar::GetUtf8(char _output[5]) const
|
||||
{
|
||||
uint32_t value = GetUtf8();
|
||||
if (0xFF >= value) {
|
||||
_output[0] = (char)value;
|
||||
_output[1] = '\0';
|
||||
return 1;
|
||||
} else if (0xFFFF >= value) {
|
||||
_output[0] = (char)((value>>8) & 0x000000FF);
|
||||
_output[1] = (char)value;
|
||||
_output[2] = '\0';
|
||||
return 2;
|
||||
} else if (0xFFFFFF >= value) {
|
||||
_output[0] = (char)((value>>16) & 0x000000FF);
|
||||
_output[1] = (char)((value>>8) & 0x000000FF);
|
||||
_output[2] = (char)value;
|
||||
_output[3] = '\0';
|
||||
return 3;
|
||||
} else {
|
||||
_output[0] = (char)((value>>24) & 0x000000FF);
|
||||
_output[1] = (char)((value>>16) & 0x000000FF);
|
||||
_output[2] = (char)((value>>8) & 0x000000FF);
|
||||
_output[3] = (char)value;
|
||||
_output[4] = '\0';
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
void etk::UniChar::SetUtf8(const char* _input)
|
||||
{
|
||||
m_value = 0;
|
||||
if (NULL == _input) {
|
||||
return;
|
||||
}
|
||||
int32_t len = strlen(_input);
|
||||
switch (len) {
|
||||
case 1:
|
||||
m_value = (uint8_t)(_input[0]) & 0x7F;
|
||||
break;
|
||||
case 2:
|
||||
m_value = (((uint8_t)_input[0]) & 0x1F)<< 6;
|
||||
m_value += ((uint8_t)_input[1]) & 0x3F;
|
||||
break;
|
||||
case 3:
|
||||
m_value = (((uint8_t)_input[0]) & 0x0F)<< 12;
|
||||
m_value += (((uint8_t)_input[1]) & 0x3F)<< 6;
|
||||
m_value += ((uint8_t)_input[2]) & 0x3F;
|
||||
break;
|
||||
default:
|
||||
m_value = (((uint8_t)_input[0]) & 0x07)<< 18;
|
||||
m_value += (((uint8_t)_input[1]) & 0x3F)<< 12;
|
||||
m_value += (((uint8_t)_input[2]) & 0x3F)<< 6;
|
||||
m_value += ((uint8_t)_input[3]) & 0x3F;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
136
etk/UniChar.h
Normal file
136
etk/UniChar.h
Normal file
@ -0,0 +1,136 @@
|
||||
/**
|
||||
* @author Edouard DUPIN
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __ETK_UNI_CHAR_H__
|
||||
#define __ETK_UNI_CHAR_H__
|
||||
|
||||
namespace etk
|
||||
{
|
||||
class UniChar
|
||||
{
|
||||
private:
|
||||
uint32_t m_value;
|
||||
public:
|
||||
// note : No preset at this element to prevent unneded set
|
||||
UniChar(void) { };
|
||||
UniChar(const etk::UniChar& _obj) :
|
||||
m_value(_obj.m_value)
|
||||
{ };
|
||||
UniChar(const char _obj) :
|
||||
m_value((uint32_t)_obj)
|
||||
{ };
|
||||
~UniChar(void) {}
|
||||
|
||||
/*****************************************************
|
||||
* = assigment
|
||||
*****************************************************/
|
||||
const etk::UniChar& operator= (const etk::UniChar& _obj )
|
||||
{
|
||||
m_value = _obj.m_value;
|
||||
return *this;
|
||||
};
|
||||
/*****************************************************
|
||||
* == operator
|
||||
*****************************************************/
|
||||
bool operator== (const etk::UniChar& _obj) const
|
||||
{
|
||||
return m_value == _obj.m_value;
|
||||
};
|
||||
bool CompareNoCase(const etk::UniChar& _obj) const;
|
||||
/*****************************************************
|
||||
* != operator
|
||||
*****************************************************/
|
||||
bool operator!= (const etk::UniChar& _obj) const
|
||||
{
|
||||
return m_value != _obj.m_value;
|
||||
};
|
||||
/*****************************************************
|
||||
* > < >= <= operator
|
||||
*****************************************************/
|
||||
bool operator> (const etk::UniChar& _obj) const
|
||||
{
|
||||
return m_value > _obj.m_value;
|
||||
};
|
||||
bool operator>= (const etk::UniChar& _obj) const
|
||||
{
|
||||
return m_value >= _obj.m_value;
|
||||
};
|
||||
bool operator< (const etk::UniChar& _obj) const
|
||||
{
|
||||
return m_value < _obj.m_value;
|
||||
};
|
||||
bool operator<= (const etk::UniChar& _obj) const
|
||||
{
|
||||
return m_value <= _obj.m_value;
|
||||
};
|
||||
/*****************************************************
|
||||
* += operator
|
||||
*****************************************************/
|
||||
const etk::UniChar& operator+= (const etk::UniChar& _obj)
|
||||
{
|
||||
m_value += _obj.m_value;
|
||||
return *this;
|
||||
};
|
||||
/*****************************************************
|
||||
* + operator
|
||||
*****************************************************/
|
||||
etk::UniChar operator+ (const etk::UniChar& _obj) const
|
||||
{
|
||||
etk::UniChar tmp = *this;
|
||||
tmp += _obj;
|
||||
return tmp;
|
||||
};
|
||||
/*****************************************************
|
||||
* -= operator
|
||||
*****************************************************/
|
||||
const etk::UniChar& operator-= (const etk::UniChar& _obj)
|
||||
{
|
||||
if (_obj.m_value >= m_value) {
|
||||
m_value = 0;
|
||||
} else {
|
||||
m_value -= _obj.m_value;
|
||||
}
|
||||
return *this;
|
||||
};
|
||||
/*****************************************************
|
||||
* - operator
|
||||
*****************************************************/
|
||||
etk::UniChar operator- (const etk::UniChar& _obj) const
|
||||
{
|
||||
etk::UniChar tmp = *this;
|
||||
tmp -= _obj;
|
||||
return tmp;
|
||||
};
|
||||
/*****************************************************
|
||||
* () operator
|
||||
*****************************************************/
|
||||
//operator uint32_t() const { return m_value; };
|
||||
|
||||
bool IsInteger(void) const;
|
||||
int32_t ToInt32(void) const;
|
||||
|
||||
void Lower(void);
|
||||
UniChar ToLower(void) const;
|
||||
void Upper(void);
|
||||
UniChar ToUpper(void) const;
|
||||
|
||||
UniChar ChangeOrder(void) const;
|
||||
|
||||
uint32_t Get(void) const { return m_value; };
|
||||
void Set(uint32_t _val) { m_value = _val; };
|
||||
|
||||
uint32_t GetUtf8(void) const;
|
||||
int8_t GetUtf8(char _output[5]) const;
|
||||
void SetUtf8(const char* _input);
|
||||
};
|
||||
};
|
||||
|
||||
typedef etk::UniChar uniChar_t;
|
||||
|
||||
#endif
|
||||
|
@ -18,8 +18,6 @@
|
||||
#define __STDC_LIMIT_MACROS
|
||||
#include <stdint.h>
|
||||
|
||||
typedef uint32_t uniChar_t;
|
||||
|
||||
typedef enum {
|
||||
ERR_NONE = 0, //!< No error, luckily everything went fine
|
||||
ERR_FAIL, //!< Miscellaneous failure
|
||||
@ -34,4 +32,7 @@ typedef enum {
|
||||
#define etk_max(elemA, elemB) (((elemA)<(elemB)) ? (elemB) : (elemA))
|
||||
#define etk_avg(minimim, elem, maximum) (((minimim)>(elem)) ? (minimim) : ((maximum)<(elem)) ? (maximum) : (elem))
|
||||
|
||||
#include <etk/UniChar.h>
|
||||
|
||||
|
||||
#endif
|
||||
|
453
etk/unicode.cpp
453
etk/unicode.cpp
@ -15,38 +15,38 @@
|
||||
|
||||
|
||||
|
||||
void unicode::convertIsoToUnicode(charset_te inputCharset, char input_ISO, uniChar_t & output_Unicode)
|
||||
void unicode::convertIsoToUnicode(charset_te _inputCharset, const char _input_ISO, uniChar_t & _output_Unicode)
|
||||
{
|
||||
switch(inputCharset)
|
||||
switch(_inputCharset)
|
||||
{
|
||||
case EDN_CHARSET_ISO_8859_1: output_Unicode = TableIso8859_1[(uint32_t)input_ISO&0xFF]; break;
|
||||
case EDN_CHARSET_ISO_8859_2: output_Unicode = TableIso8859_2[(uint32_t)input_ISO&0xFF]; break;
|
||||
case EDN_CHARSET_ISO_8859_3: output_Unicode = TableIso8859_3[(uint32_t)input_ISO&0xFF]; break;
|
||||
case EDN_CHARSET_ISO_8859_4: output_Unicode = TableIso8859_4[(uint32_t)input_ISO&0xFF]; break;
|
||||
case EDN_CHARSET_ISO_8859_5: output_Unicode = TableIso8859_5[(uint32_t)input_ISO&0xFF]; break;
|
||||
case EDN_CHARSET_ISO_8859_6: output_Unicode = TableIso8859_6[(uint32_t)input_ISO&0xFF]; break;
|
||||
case EDN_CHARSET_ISO_8859_7: output_Unicode = TableIso8859_7[(uint32_t)input_ISO&0xFF]; break;
|
||||
case EDN_CHARSET_ISO_8859_8: output_Unicode = TableIso8859_8[(uint32_t)input_ISO&0xFF]; break;
|
||||
case EDN_CHARSET_ISO_8859_9: output_Unicode = TableIso8859_9[(uint32_t)input_ISO&0xFF]; break;
|
||||
case EDN_CHARSET_ISO_8859_10: output_Unicode = TableIso8859_10[(uint32_t)input_ISO&0xFF]; break;
|
||||
case EDN_CHARSET_ISO_8859_11: output_Unicode = TableIso8859_11[(uint32_t)input_ISO&0xFF]; break;
|
||||
case EDN_CHARSET_ISO_8859_13: output_Unicode = TableIso8859_13[(uint32_t)input_ISO&0xFF]; break;
|
||||
case EDN_CHARSET_ISO_8859_14: output_Unicode = TableIso8859_14[(uint32_t)input_ISO&0xFF]; break;
|
||||
case EDN_CHARSET_ISO_8859_1: _output_Unicode.Set(TableIso8859_1[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_2: _output_Unicode.Set(TableIso8859_2[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_3: _output_Unicode.Set(TableIso8859_3[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_4: _output_Unicode.Set(TableIso8859_4[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_5: _output_Unicode.Set(TableIso8859_5[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_6: _output_Unicode.Set(TableIso8859_6[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_7: _output_Unicode.Set(TableIso8859_7[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_8: _output_Unicode.Set(TableIso8859_8[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_9: _output_Unicode.Set(TableIso8859_9[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_10: _output_Unicode.Set(TableIso8859_10[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_11: _output_Unicode.Set(TableIso8859_11[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_13: _output_Unicode.Set(TableIso8859_13[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_14: _output_Unicode.Set(TableIso8859_14[(uint32_t)_input_ISO&0xFF]); break;
|
||||
case EDN_CHARSET_ISO_8859_15:
|
||||
output_Unicode = TableIso8859_15[(uint32_t)input_ISO&0xFF];
|
||||
_output_Unicode = TableIso8859_15[(uint32_t)_input_ISO&0xFF];
|
||||
break;
|
||||
default :
|
||||
TK_WARNING("Unknow charset ... " << inputCharset);
|
||||
output_Unicode = '?';
|
||||
TK_WARNING("Unknow charset ... " << _inputCharset);
|
||||
_output_Unicode = '?';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void unicode::convertUnicodeToIso(charset_te inputCharset, uniChar_t input_Unicode, char & output_ISO)
|
||||
void unicode::convertUnicodeToIso(charset_te _inputCharset, const uniChar_t _input_Unicode, char & _output_ISO)
|
||||
{
|
||||
const uniChar_t *tmpTable = NULL;
|
||||
switch(inputCharset)
|
||||
const uint32_t *tmpTable = NULL;
|
||||
switch(_inputCharset)
|
||||
{
|
||||
case EDN_CHARSET_ISO_8859_1: tmpTable = TableIso8859_1; break;
|
||||
case EDN_CHARSET_ISO_8859_2: tmpTable = TableIso8859_2; break;
|
||||
@ -63,245 +63,158 @@ void unicode::convertUnicodeToIso(charset_te inputCharset, uniChar_t input_Unico
|
||||
case EDN_CHARSET_ISO_8859_14: tmpTable = TableIso8859_14; break;
|
||||
case EDN_CHARSET_ISO_8859_15: tmpTable = TableIso8859_15; break;
|
||||
default :
|
||||
TK_WARNING("Unknow charset ... " << inputCharset);
|
||||
output_ISO = '?';
|
||||
TK_WARNING("Unknow charset ... " << _inputCharset);
|
||||
_output_ISO = '?';
|
||||
return;
|
||||
}
|
||||
int32_t i;
|
||||
for (i=0; i<256; i++) {
|
||||
if (tmpTable[i] == input_Unicode) {
|
||||
output_ISO = (char)i;
|
||||
if (tmpTable[i] == _input_Unicode.Get()) {
|
||||
_output_ISO = (char)i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t unicode::convertIsoToUnicode(charset_te inputCharset, etk::Vector<char>& input_ISO, etk::Vector<uniChar_t>& output_Unicode)
|
||||
int32_t unicode::convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<uniChar_t>& _output_Unicode)
|
||||
{
|
||||
output_Unicode.Clear();
|
||||
_output_Unicode.Clear();
|
||||
uniChar_t output;
|
||||
for(int32_t iii=0; iii<input_ISO.Size(); iii++) {
|
||||
convertIsoToUnicode(inputCharset, (char)input_ISO[iii], output);
|
||||
output_Unicode.PushBack(output);
|
||||
for(int32_t iii=0; iii<_input_ISO.Size(); iii++) {
|
||||
convertIsoToUnicode(_inputCharset, (char)_input_ISO[iii], output);
|
||||
_output_Unicode.PushBack(output);
|
||||
}
|
||||
if (output_Unicode.Size() == 0) {
|
||||
output_Unicode.PushBack(0);
|
||||
} else if (output_Unicode[output_Unicode.Size()-1] != 0) {
|
||||
output_Unicode.PushBack(0);
|
||||
if (_output_Unicode.Size() == 0) {
|
||||
_output_Unicode.PushBack(0);
|
||||
} else if (_output_Unicode[_output_Unicode.Size()-1] != 0) {
|
||||
_output_Unicode.PushBack(0);
|
||||
}
|
||||
return output_Unicode.Size();
|
||||
return _output_Unicode.Size();
|
||||
}
|
||||
|
||||
int32_t unicode::convertIsoToUnicode(charset_te inputCharset, etk::Vector<int8_t>& input_ISO, etk::Vector<uniChar_t>& output_Unicode)
|
||||
int32_t unicode::convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<int8_t>& _input_ISO, etk::Vector<uniChar_t>& _output_Unicode)
|
||||
{
|
||||
output_Unicode.Clear();
|
||||
_output_Unicode.Clear();
|
||||
uniChar_t output;
|
||||
for(int32_t iii=0; iii<input_ISO.Size(); iii++) {
|
||||
convertIsoToUnicode(inputCharset, (char)input_ISO[iii], output);
|
||||
output_Unicode.PushBack(output);
|
||||
for(int32_t iii=0; iii<_input_ISO.Size(); iii++) {
|
||||
convertIsoToUnicode(_inputCharset, (char)_input_ISO[iii], output);
|
||||
_output_Unicode.PushBack(output);
|
||||
}
|
||||
if (output_Unicode.Size() == 0) {
|
||||
output_Unicode.PushBack(0);
|
||||
} else if (output_Unicode[output_Unicode.Size()-1] != 0) {
|
||||
output_Unicode.PushBack(0);
|
||||
if (_output_Unicode.Size() == 0) {
|
||||
_output_Unicode.PushBack(0);
|
||||
} else if (_output_Unicode[_output_Unicode.Size()-1] != 0) {
|
||||
_output_Unicode.PushBack(0);
|
||||
}
|
||||
return output_Unicode.Size();
|
||||
return _output_Unicode.Size();
|
||||
}
|
||||
|
||||
|
||||
int32_t unicode::convertUnicodeToIso(charset_te inputCharset, etk::Vector<uniChar_t>& input_Unicode, etk::Vector<char>& output_ISO)
|
||||
int32_t unicode::convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<char>& _output_ISO)
|
||||
{
|
||||
output_ISO.Clear();
|
||||
_output_ISO.Clear();
|
||||
char output[10];
|
||||
for(int32_t iii=0; iii<input_Unicode.Size(); iii++) {
|
||||
convertUnicodeToUtf8(input_Unicode[iii], output);
|
||||
for(int32_t iii=0; iii<_input_Unicode.Size(); iii++) {
|
||||
_input_Unicode[iii].GetUtf8(output);
|
||||
char * tmp = output;
|
||||
while(*tmp != '\0') {
|
||||
output_ISO.PushBack(*tmp);
|
||||
_output_ISO.PushBack(*tmp);
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
output_ISO.PushBack(0);
|
||||
return output_ISO.Size();
|
||||
_output_ISO.PushBack(0);
|
||||
return _output_ISO.Size();
|
||||
}
|
||||
|
||||
int32_t unicode::convertUnicodeToIso(charset_te inputCharset, etk::Vector<uniChar_t>& input_Unicode, etk::Vector<int8_t>& output_ISO)
|
||||
int32_t unicode::convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<int8_t>& _output_ISO)
|
||||
{
|
||||
output_ISO.Clear();
|
||||
_output_ISO.Clear();
|
||||
char output[10];
|
||||
for(int32_t iii=0; iii<input_Unicode.Size(); iii++) {
|
||||
convertUnicodeToUtf8(input_Unicode[iii], output);
|
||||
for(int32_t iii=0; iii<_input_Unicode.Size(); iii++) {
|
||||
_input_Unicode[iii].GetUtf8(output);
|
||||
char * tmp = output;
|
||||
while(*tmp != '\0') {
|
||||
output_ISO.PushBack(*tmp);
|
||||
_output_ISO.PushBack(*tmp);
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
output_ISO.PushBack(0);
|
||||
return output_ISO.Size();
|
||||
}
|
||||
|
||||
|
||||
static uint32_t unicodeToUtf8(uniChar_t value)
|
||||
{
|
||||
uint32_t output = 0;
|
||||
if (127 >= value) {
|
||||
output = value;
|
||||
} else if (2047 >= value) {
|
||||
// output ==> 00000000 00000000 110xxxxx 10xxxxxx
|
||||
// input ==> -------- -------- -----222 22111111
|
||||
output = 0x0000C080;
|
||||
output+= (value & 0x000007C0)<<2;
|
||||
output+= value & 0x0000003F;
|
||||
} else if (65535 >= value) {
|
||||
// output ==> 00000000 1110xxxx 10xxxxxx 10xxxxxx
|
||||
// input ==> -------- -------- 33332222 22111111
|
||||
output = 0x00E08080;
|
||||
output+= (value & 0x0000F000)<<4;
|
||||
output+= (value & 0x00000FC0)<<2;
|
||||
output+= value & 0x0000003F;
|
||||
} else if (1114111 >= value) {
|
||||
// output ==> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
// input ==> -------- ---44433 33332222 22111111
|
||||
output = 0xF0808080;
|
||||
output+= (value & 0x001C0000)<<6;
|
||||
output+= (value & 0x0003F000)<<4;
|
||||
output+= (value & 0x00000FC0)<<2;
|
||||
output+= value & 0x0000003F;
|
||||
} else {
|
||||
TK_ERROR("NON UTF8 caracter input...");
|
||||
return 0;
|
||||
}
|
||||
//printf("utf8convertion : %d=%08x ==> %08x\n",value, value, output);
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
void unicode::convertUnicodeToUtf8(uniChar_t input_Unicode, char * output_UTF8)
|
||||
{
|
||||
uint32_t value = unicodeToUtf8(input_Unicode);
|
||||
if (0xFF >= value) {
|
||||
output_UTF8[0] = (char)value;
|
||||
output_UTF8[1] = '\0';
|
||||
} else if (0xFFFF >= value) {
|
||||
output_UTF8[0] = (char)((value>>8) & 0x000000FF);
|
||||
output_UTF8[1] = (char)value;
|
||||
output_UTF8[2] = '\0';
|
||||
} else if (0xFFFFFF >= value) {
|
||||
output_UTF8[0] = (char)((value>>16) & 0x000000FF);
|
||||
output_UTF8[1] = (char)((value>>8) & 0x000000FF);
|
||||
output_UTF8[2] = (char)value;
|
||||
output_UTF8[3] = '\0';
|
||||
} else {
|
||||
output_UTF8[0] = (char)((value>>24) & 0x000000FF);
|
||||
output_UTF8[1] = (char)((value>>16) & 0x000000FF);
|
||||
output_UTF8[2] = (char)((value>>8) & 0x000000FF);
|
||||
output_UTF8[3] = (char)value;
|
||||
output_UTF8[4] = '\0';
|
||||
}
|
||||
_output_ISO.PushBack(0);
|
||||
return _output_ISO.Size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void unicode::convertUtf8ToUnicode(char * input_UTF8, uniChar_t &output_Unicode)
|
||||
{
|
||||
int32_t len = strlen(input_UTF8);
|
||||
output_Unicode = 0;
|
||||
switch (len) {
|
||||
case 1:
|
||||
output_Unicode = (uint8_t)(input_UTF8[0]) & 0x7F;
|
||||
break;
|
||||
case 2:
|
||||
output_Unicode = (((uint8_t)input_UTF8[0]) & 0x1F)<< 6;
|
||||
output_Unicode += ((uint8_t)input_UTF8[1]) & 0x3F;
|
||||
break;
|
||||
case 3:
|
||||
output_Unicode = (((uint8_t)input_UTF8[0]) & 0x0F)<< 12;
|
||||
output_Unicode += (((uint8_t)input_UTF8[1]) & 0x3F)<< 6;
|
||||
output_Unicode += ((uint8_t)input_UTF8[2]) & 0x3F;
|
||||
break;
|
||||
default:
|
||||
output_Unicode = (((uint8_t)input_UTF8[0]) & 0x07)<< 18;
|
||||
output_Unicode += (((uint8_t)input_UTF8[1]) & 0x3F)<< 12;
|
||||
output_Unicode += (((uint8_t)input_UTF8[2]) & 0x3F)<< 6;
|
||||
output_Unicode += ((uint8_t)input_UTF8[3]) & 0x3F;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int32_t unicode::convertUnicodeToUtf8(const etk::Vector<uniChar_t>& input_Unicode, etk::Vector<char>& output_UTF8)
|
||||
int32_t unicode::convertUnicodeToUtf8(const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<char>& _output_UTF8)
|
||||
{
|
||||
char output[10];
|
||||
|
||||
for (int32_t iii=0; iii<input_Unicode.Size(); iii++) {
|
||||
unicode::convertUnicodeToUtf8(input_Unicode[iii], output);
|
||||
for (int32_t iii=0; iii<_input_Unicode.Size(); iii++) {
|
||||
_input_Unicode[iii].GetUtf8(output);
|
||||
char * tmp = output ;
|
||||
while (*tmp != '\0') {
|
||||
output_UTF8.PushBack(*tmp);
|
||||
_output_UTF8.PushBack(*tmp);
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
output_UTF8.PushBack('\0');
|
||||
return output_UTF8.Size()-1;
|
||||
_output_UTF8.PushBack('\0');
|
||||
return _output_UTF8.Size()-1;
|
||||
}
|
||||
|
||||
int32_t unicode::convertUnicodeToUtf8(const etk::Vector<uniChar_t>& input_Unicode, etk::Vector<int8_t>& output_UTF8)
|
||||
int32_t unicode::convertUnicodeToUtf8(const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<int8_t>& _output_UTF8)
|
||||
{
|
||||
char output[10];
|
||||
|
||||
for (int32_t iii=0; iii<input_Unicode.Size(); iii++) {
|
||||
unicode::convertUnicodeToUtf8(input_Unicode[iii], output);
|
||||
for (int32_t iii=0; iii<_input_Unicode.Size(); iii++) {
|
||||
_input_Unicode[iii].GetUtf8(output);
|
||||
char * tmp = output ;
|
||||
while (*tmp != '\0') {
|
||||
output_UTF8.PushBack((int8_t)*tmp);
|
||||
_output_UTF8.PushBack((int8_t)*tmp);
|
||||
tmp++;
|
||||
}
|
||||
}
|
||||
output_UTF8.PushBack('\0');
|
||||
return output_UTF8.Size()-1;
|
||||
_output_UTF8.PushBack('\0');
|
||||
return _output_UTF8.Size()-1;
|
||||
}
|
||||
|
||||
|
||||
int32_t unicode::convertUtf8ToUnicode(etk::Vector<char>& input_UTF8, etk::Vector<uniChar_t>& output_Unicode)
|
||||
int32_t unicode::convertUtf8ToUnicode(const etk::Vector<char>& _input_UTF8, etk::Vector<uniChar_t>& _output_Unicode)
|
||||
{
|
||||
char tmpData[20];
|
||||
int32_t pos = 0;
|
||||
while (pos < input_UTF8.Size()) {
|
||||
int32_t lenMax = input_UTF8.Size() - pos;
|
||||
while (pos < _input_UTF8.Size()) {
|
||||
int32_t lenMax = _input_UTF8.Size() - pos;
|
||||
//4 case
|
||||
if( 1<=lenMax
|
||||
&& 0x00 == (input_UTF8[pos+0] & 0x80) )
|
||||
&& 0x00 == (_input_UTF8[pos+0] & 0x80) )
|
||||
{
|
||||
tmpData[0] = input_UTF8[pos+0];
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = '\0';
|
||||
pos += 1;
|
||||
} else if( 2<=lenMax
|
||||
&& 0xC0 == (input_UTF8[pos+0] & 0xE0)
|
||||
&& 0x80 == (input_UTF8[pos+1] & 0xC0) ) {
|
||||
tmpData[0] = input_UTF8[pos+0];
|
||||
tmpData[1] = input_UTF8[pos+1];
|
||||
&& 0xC0 == (_input_UTF8[pos+0] & 0xE0)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0) ) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = '\0';
|
||||
pos += 2;
|
||||
} else if( 3<=lenMax
|
||||
&& 0xE0 == (input_UTF8[pos+0] & 0xF0)
|
||||
&& 0x80 == (input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (input_UTF8[pos+2] & 0xC0)) {
|
||||
tmpData[0] = input_UTF8[pos+0];
|
||||
tmpData[1] = input_UTF8[pos+1];
|
||||
tmpData[2] = input_UTF8[pos+2];
|
||||
&& 0xE0 == (_input_UTF8[pos+0] & 0xF0)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+2] & 0xC0)) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = _input_UTF8[pos+2];
|
||||
tmpData[3] = '\0';
|
||||
pos += 3;
|
||||
} else if( 4<=lenMax
|
||||
&& 0xF0 == (input_UTF8[pos+0] & 0xF8)
|
||||
&& 0x80 == (input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (input_UTF8[pos+2] & 0xC0)
|
||||
&& 0x80 == (input_UTF8[pos+3] & 0xC0)) {
|
||||
tmpData[0] = input_UTF8[pos+0];
|
||||
tmpData[1] = input_UTF8[pos+1];
|
||||
tmpData[2] = input_UTF8[pos+2];
|
||||
tmpData[3] = input_UTF8[pos+3];
|
||||
&& 0xF0 == (_input_UTF8[pos+0] & 0xF8)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+2] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+3] & 0xC0)) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = _input_UTF8[pos+2];
|
||||
tmpData[3] = _input_UTF8[pos+3];
|
||||
tmpData[4] = '\0';
|
||||
pos += 4;
|
||||
} else {
|
||||
@ -309,50 +222,50 @@ int32_t unicode::convertUtf8ToUnicode(etk::Vector<char>& input_UTF8, etk::Vector
|
||||
pos += 1;
|
||||
}
|
||||
uniChar_t tmpUnicode;
|
||||
convertUtf8ToUnicode(tmpData, tmpUnicode);
|
||||
output_Unicode.PushBack(tmpUnicode);
|
||||
tmpUnicode.SetUtf8(tmpData);
|
||||
_output_Unicode.PushBack(tmpUnicode);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t unicode::convertUtf8ToUnicode(etk::Vector<int8_t>& input_UTF8, etk::Vector<uniChar_t>& output_Unicode)
|
||||
int32_t unicode::convertUtf8ToUnicode(const etk::Vector<int8_t>& _input_UTF8, etk::Vector<uniChar_t>& _output_Unicode)
|
||||
{
|
||||
char tmpData[20];
|
||||
int32_t pos = 0;
|
||||
while (pos < input_UTF8.Size()) {
|
||||
int32_t lenMax = input_UTF8.Size() - pos;
|
||||
while (pos < _input_UTF8.Size()) {
|
||||
int32_t lenMax = _input_UTF8.Size() - pos;
|
||||
//4 case
|
||||
if( 1<=lenMax
|
||||
&& 0x00 == (input_UTF8[pos+0] & 0x80) )
|
||||
&& 0x00 == (_input_UTF8[pos+0] & 0x80) )
|
||||
{
|
||||
tmpData[0] = input_UTF8[pos+0];
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = '\0';
|
||||
pos += 1;
|
||||
} else if( 2<=lenMax
|
||||
&& 0xC0 == (input_UTF8[pos+0] & 0xE0)
|
||||
&& 0x80 == (input_UTF8[pos+1] & 0xC0) ) {
|
||||
tmpData[0] = input_UTF8[pos+0];
|
||||
tmpData[1] = input_UTF8[pos+1];
|
||||
&& 0xC0 == (_input_UTF8[pos+0] & 0xE0)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0) ) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = '\0';
|
||||
pos += 2;
|
||||
} else if( 3<=lenMax
|
||||
&& 0xE0 == (input_UTF8[pos+0] & 0xF0)
|
||||
&& 0x80 == (input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (input_UTF8[pos+2] & 0xC0)) {
|
||||
tmpData[0] = input_UTF8[pos+0];
|
||||
tmpData[1] = input_UTF8[pos+1];
|
||||
tmpData[2] = input_UTF8[pos+2];
|
||||
&& 0xE0 == (_input_UTF8[pos+0] & 0xF0)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+2] & 0xC0)) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = _input_UTF8[pos+2];
|
||||
tmpData[3] = '\0';
|
||||
pos += 3;
|
||||
} else if( 4<=lenMax
|
||||
&& 0xF0 == (input_UTF8[pos+0] & 0xF8)
|
||||
&& 0x80 == (input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (input_UTF8[pos+2] & 0xC0)
|
||||
&& 0x80 == (input_UTF8[pos+3] & 0xC0)) {
|
||||
tmpData[0] = input_UTF8[pos+0];
|
||||
tmpData[1] = input_UTF8[pos+1];
|
||||
tmpData[2] = input_UTF8[pos+2];
|
||||
tmpData[3] = input_UTF8[pos+3];
|
||||
&& 0xF0 == (_input_UTF8[pos+0] & 0xF8)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+2] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+3] & 0xC0)) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = _input_UTF8[pos+2];
|
||||
tmpData[3] = _input_UTF8[pos+3];
|
||||
tmpData[4] = '\0';
|
||||
pos += 4;
|
||||
} else {
|
||||
@ -360,54 +273,54 @@ int32_t unicode::convertUtf8ToUnicode(etk::Vector<int8_t>& input_UTF8, etk::Vect
|
||||
pos += 1;
|
||||
}
|
||||
uniChar_t tmpUnicode;
|
||||
convertUtf8ToUnicode(tmpData, tmpUnicode);
|
||||
output_Unicode.PushBack(tmpUnicode);
|
||||
tmpUnicode.SetUtf8(tmpData);
|
||||
_output_Unicode.PushBack(tmpUnicode);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t unicode::convertUtf8ToUnicode(char * input_UTF8, etk::Vector<uniChar_t>& output_Unicode)
|
||||
int32_t unicode::convertUtf8ToUnicode(const char * _input_UTF8, etk::Vector<uniChar_t>& _output_Unicode)
|
||||
{
|
||||
char tmpData[20];
|
||||
int32_t pos = 0;
|
||||
if (NULL == input_UTF8) {
|
||||
if (NULL == _input_UTF8) {
|
||||
return 0;
|
||||
}
|
||||
int32_t len = strlen(input_UTF8);
|
||||
int32_t len = strlen(_input_UTF8);
|
||||
while (pos < len) {
|
||||
int32_t lenMax = len - pos;
|
||||
//4 case
|
||||
if( 1<=lenMax
|
||||
&& 0x00 == (input_UTF8[pos+0] & 0x80) )
|
||||
&& 0x00 == (_input_UTF8[pos+0] & 0x80) )
|
||||
{
|
||||
tmpData[0] = input_UTF8[pos+0];
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = '\0';
|
||||
pos += 1;
|
||||
} else if( 2<=lenMax
|
||||
&& 0xC0 == (input_UTF8[pos+0] & 0xE0)
|
||||
&& 0x80 == (input_UTF8[pos+1] & 0xC0) ) {
|
||||
tmpData[0] = input_UTF8[pos+0];
|
||||
tmpData[1] = input_UTF8[pos+1];
|
||||
&& 0xC0 == (_input_UTF8[pos+0] & 0xE0)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0) ) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = '\0';
|
||||
pos += 2;
|
||||
} else if( 3<=lenMax
|
||||
&& 0xE0 == (input_UTF8[pos+0] & 0xF0)
|
||||
&& 0x80 == (input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (input_UTF8[pos+2] & 0xC0)) {
|
||||
tmpData[0] = input_UTF8[pos+0];
|
||||
tmpData[1] = input_UTF8[pos+1];
|
||||
tmpData[2] = input_UTF8[pos+2];
|
||||
&& 0xE0 == (_input_UTF8[pos+0] & 0xF0)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+2] & 0xC0)) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = _input_UTF8[pos+2];
|
||||
tmpData[3] = '\0';
|
||||
pos += 3;
|
||||
} else if( 4<=lenMax
|
||||
&& 0xF0 == (input_UTF8[pos+0] & 0xF8)
|
||||
&& 0x80 == (input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (input_UTF8[pos+2] & 0xC0)
|
||||
&& 0x80 == (input_UTF8[pos+3] & 0xC0)) {
|
||||
tmpData[0] = input_UTF8[pos+0];
|
||||
tmpData[1] = input_UTF8[pos+1];
|
||||
tmpData[2] = input_UTF8[pos+2];
|
||||
tmpData[3] = input_UTF8[pos+3];
|
||||
&& 0xF0 == (_input_UTF8[pos+0] & 0xF8)
|
||||
&& 0x80 == (_input_UTF8[pos+1] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+2] & 0xC0)
|
||||
&& 0x80 == (_input_UTF8[pos+3] & 0xC0)) {
|
||||
tmpData[0] = _input_UTF8[pos+0];
|
||||
tmpData[1] = _input_UTF8[pos+1];
|
||||
tmpData[2] = _input_UTF8[pos+2];
|
||||
tmpData[3] = _input_UTF8[pos+3];
|
||||
tmpData[4] = '\0';
|
||||
pos += 4;
|
||||
} else {
|
||||
@ -415,83 +328,83 @@ int32_t unicode::convertUtf8ToUnicode(char * input_UTF8, etk::Vector<uniChar_t>&
|
||||
pos += 1;
|
||||
}
|
||||
uniChar_t tmpUnicode;
|
||||
convertUtf8ToUnicode(tmpData, tmpUnicode);
|
||||
output_Unicode.PushBack(tmpUnicode);
|
||||
tmpUnicode.SetUtf8(tmpData);
|
||||
_output_Unicode.PushBack(tmpUnicode);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// Transform ISO <==> UTF-8
|
||||
void unicode::convertIsoToUtf8(charset_te inputCharset, char input_ISO, char * output_UTF8)
|
||||
void unicode::convertIsoToUtf8(charset_te _inputCharset, const char _input_ISO, char * _output_UTF8)
|
||||
{
|
||||
uniChar_t tmpUnicode;
|
||||
// concert Iso in UniCode
|
||||
convertIsoToUnicode(inputCharset, input_ISO, tmpUnicode );
|
||||
convertIsoToUnicode(_inputCharset, _input_ISO, tmpUnicode );
|
||||
// convert UniCode in Utf-8
|
||||
convertUnicodeToUtf8(tmpUnicode, output_UTF8);
|
||||
tmpUnicode.GetUtf8(_output_UTF8);
|
||||
}
|
||||
|
||||
|
||||
void unicode::convertUtf8ToIso(charset_te inputCharset, char * input_UTF8, char & output_ISO)
|
||||
void unicode::convertUtf8ToIso(charset_te _inputCharset, const char * _input_UTF8, char & _output_ISO)
|
||||
{
|
||||
uniChar_t tmpUnicode;
|
||||
// convert Utf-8 in UniCode
|
||||
convertUtf8ToUnicode(input_UTF8, tmpUnicode);
|
||||
tmpUnicode.SetUtf8(_input_UTF8);
|
||||
// concert UniCode in Iso
|
||||
convertUnicodeToIso(inputCharset, tmpUnicode, output_ISO);
|
||||
convertUnicodeToIso(_inputCharset, tmpUnicode, _output_ISO);
|
||||
}
|
||||
|
||||
|
||||
int32_t unicode::convertIsoToUtf8(charset_te inputCharset, etk::Vector<char>& input_ISO, etk::Vector<char>& output_UTF8)
|
||||
int32_t unicode::convertIsoToUtf8(charset_te _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<char>& _output_UTF8)
|
||||
{
|
||||
TK_WARNING("TODO : not coded...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t unicode::convertUtf8ToIso(charset_te inputCharset, etk::Vector<char>& input_UTF8, etk::Vector<char>& output_ISO)
|
||||
int32_t unicode::convertUtf8ToIso(charset_te _inputCharset, const etk::Vector<char>& _input_UTF8, etk::Vector<char>& _output_ISO)
|
||||
{
|
||||
TK_WARNING("TODO : not coded...");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void unicode::Utf8_SizeElement(const char * data, int32_t lenMax , uint8_t &size, bool &baseValid)
|
||||
void unicode::Utf8_SizeElement(const char * _data, int32_t _lenMax , uint8_t &_size, bool &_baseValid)
|
||||
{
|
||||
TK_ASSERT(0 <= lenMax, "size can not be < 0 ...");
|
||||
if (0 > lenMax) {
|
||||
size = 0;
|
||||
baseValid = false;
|
||||
TK_ASSERT(0 <= _lenMax, "size can not be < 0 ...");
|
||||
if (0 > _lenMax) {
|
||||
_size = 0;
|
||||
_baseValid = false;
|
||||
return;
|
||||
}
|
||||
//4 case
|
||||
if ( 1<=lenMax
|
||||
&& 0x00 == (data[0] & 0x80) ) {
|
||||
if ( 1<=_lenMax
|
||||
&& 0x00 == (_data[0] & 0x80) ) {
|
||||
// One Char Element
|
||||
size = 1;
|
||||
baseValid = true;
|
||||
} else if( 2<=lenMax
|
||||
&& 0xC0 == (data[0] & 0xE0)
|
||||
&& 0x80 == (data[1] & 0xC0) ) {
|
||||
size = 2;
|
||||
baseValid = true;
|
||||
} else if( 3<=lenMax
|
||||
&& 0xE0 == (data[0] & 0xF0)
|
||||
&& 0x80 == (data[1] & 0xC0)
|
||||
&& 0x80 == (data[2] & 0xC0)) {
|
||||
size = 3;
|
||||
baseValid = true;
|
||||
} else if( 4<=lenMax
|
||||
&& 0xF0 == (data[0] & 0xF8)
|
||||
&& 0x80 == (data[1] & 0xC0)
|
||||
&& 0x80 == (data[2] & 0xC0)
|
||||
&& 0x80 == (data[3] & 0xC0)) {
|
||||
size = 4;
|
||||
baseValid = true;
|
||||
_size = 1;
|
||||
_baseValid = true;
|
||||
} else if( 2<=_lenMax
|
||||
&& 0xC0 == (_data[0] & 0xE0)
|
||||
&& 0x80 == (_data[1] & 0xC0) ) {
|
||||
_size = 2;
|
||||
_baseValid = true;
|
||||
} else if( 3<=_lenMax
|
||||
&& 0xE0 == (_data[0] & 0xF0)
|
||||
&& 0x80 == (_data[1] & 0xC0)
|
||||
&& 0x80 == (_data[2] & 0xC0)) {
|
||||
_size = 3;
|
||||
_baseValid = true;
|
||||
} else if( 4<=_lenMax
|
||||
&& 0xF0 == (_data[0] & 0xF8)
|
||||
&& 0x80 == (_data[1] & 0xC0)
|
||||
&& 0x80 == (_data[2] & 0xC0)
|
||||
&& 0x80 == (_data[3] & 0xC0)) {
|
||||
_size = 4;
|
||||
_baseValid = true;
|
||||
} else {
|
||||
// return only one error Caracter ...
|
||||
baseValid = false;
|
||||
size = 1;
|
||||
_baseValid = false;
|
||||
_size = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,28 +32,26 @@ namespace unicode {
|
||||
} charset_te;
|
||||
|
||||
// transform ISO <==> Unicode
|
||||
void convertIsoToUnicode(charset_te inputCharset, char input_ISO, uniChar_t & output_Unicode);
|
||||
void convertUnicodeToIso(charset_te inputCharset, uniChar_t input_Unicode, char & output_ISO);
|
||||
int32_t convertIsoToUnicode(charset_te inputCharset, etk::Vector<char>& input_ISO, etk::Vector<uniChar_t>& output_Unicode);
|
||||
int32_t convertIsoToUnicode(charset_te inputCharset, etk::Vector<int8_t>& input_ISO, etk::Vector<uniChar_t>& output_Unicode);
|
||||
int32_t convertUnicodeToIso(charset_te inputCharset, etk::Vector<uniChar_t>& input_Unicode, etk::Vector<char>& output_ISO);
|
||||
int32_t convertUnicodeToIso(charset_te inputCharset, etk::Vector<uniChar_t>& input_Unicode, etk::Vector<int8_t>& output_ISO);
|
||||
void convertIsoToUnicode(charset_te _inputCharset, const char _input_ISO, uniChar_t & _output_Unicode);
|
||||
void convertUnicodeToIso(charset_te _inputCharset, const uniChar_t _input_Unicode, char & _output_ISO);
|
||||
int32_t convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<uniChar_t>& _output_Unicode);
|
||||
int32_t convertIsoToUnicode(charset_te _inputCharset, const etk::Vector<int8_t>& _input_ISO, etk::Vector<uniChar_t>& _output_Unicode);
|
||||
int32_t convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<char>& _output_ISO);
|
||||
int32_t convertUnicodeToIso(charset_te _inputCharset, const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<int8_t>& _output_ISO);
|
||||
// Transform UTF-8 <==> Unicode
|
||||
void convertUnicodeToUtf8( uniChar_t input_Unicode, char * output_UTF8);
|
||||
void convertUtf8ToUnicode( char * input_UTF8, uniChar_t& output_Unicode);
|
||||
int32_t convertUnicodeToUtf8( const etk::Vector<uniChar_t>& input_Unicode, etk::Vector<char>& output_UTF8);
|
||||
int32_t convertUnicodeToUtf8( const etk::Vector<uniChar_t>& input_Unicode, etk::Vector<int8_t>& output_UTF8);
|
||||
int32_t convertUtf8ToUnicode( etk::Vector<char>& input_UTF8, etk::Vector<uniChar_t>& output_Unicode);
|
||||
int32_t convertUtf8ToUnicode( etk::Vector<int8_t>& input_UTF8, etk::Vector<uniChar_t>& output_Unicode);
|
||||
int32_t convertUtf8ToUnicode( char * input_UTF8, etk::Vector<uniChar_t>& output_Unicode);
|
||||
int32_t convertUnicodeToUtf8( const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<char>& _output_UTF8);
|
||||
int32_t convertUnicodeToUtf8( const etk::Vector<uniChar_t>& _input_Unicode, etk::Vector<int8_t>& _output_UTF8);
|
||||
int32_t convertUtf8ToUnicode( const etk::Vector<char>& _input_UTF8, etk::Vector<uniChar_t>& _output_Unicode);
|
||||
int32_t convertUtf8ToUnicode( const etk::Vector<int8_t>& _input_UTF8, etk::Vector<uniChar_t>& _output_Unicode);
|
||||
int32_t convertUtf8ToUnicode( const char * _input_UTF8, etk::Vector<uniChar_t>& _output_Unicode);
|
||||
// Transform ISO <==> UTF-8
|
||||
void convertIsoToUtf8( charset_te inputCharset, char input_ISO, char * output_UTF8);
|
||||
void convertUtf8ToIso( charset_te inputCharset, char * input_UTF8, char & output_ISO);
|
||||
int32_t convertIsoToUtf8( charset_te inputCharset, etk::Vector<char>& input_ISO, etk::Vector<char>& output_UTF8);
|
||||
int32_t convertUtf8ToIso( charset_te inputCharset, etk::Vector<char>& input_UTF8, etk::Vector<char>& output_ISO);
|
||||
void convertIsoToUtf8( charset_te _inputCharset, const char _input_ISO, char * _output_UTF8);
|
||||
void convertUtf8ToIso( charset_te _inputCharset, const char * _input_UTF8, char & _output_ISO);
|
||||
int32_t convertIsoToUtf8( charset_te _inputCharset, const etk::Vector<char>& _input_ISO, etk::Vector<char>& _output_UTF8);
|
||||
int32_t convertUtf8ToIso( charset_te _inputCharset, const etk::Vector<char>& _input_UTF8, etk::Vector<char>& _output_ISO);
|
||||
|
||||
void Utf8_SizeElement(const char * data, int32_t lenMax , uint8_t &size, bool &baseValid);
|
||||
int32_t strUtf8Len(const char *input_UTF8);
|
||||
void Utf8_SizeElement(const char * _data, int32_t _lenMax , uint8_t &_size, bool &_baseValid);
|
||||
int32_t strUtf8Len(const char *_input_UTF8);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
const uniChar_t TableIso8859_1[] = {
|
||||
const uint32_t TableIso8859_1[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -31,7 +31,7 @@ extern "C" {
|
||||
0x000000F0, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x000000FE, 0x000000FF
|
||||
};
|
||||
|
||||
const uniChar_t TableIso8859_2[] = {
|
||||
const uint32_t TableIso8859_2[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -50,7 +50,7 @@ extern "C" {
|
||||
0x00000111, 0x00000144, 0x00000148, 0x000000F3, 0x000000F4, 0x00000151, 0x000000F6, 0x000000F7, 0x00000159, 0x0000016F, 0x000000FA, 0x00000171, 0x000000FC, 0x000000FD, 0x00000163, 0x000002D9
|
||||
};
|
||||
|
||||
const uniChar_t TableIso8859_3[] = {
|
||||
const uint32_t TableIso8859_3[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -69,7 +69,7 @@ extern "C" {
|
||||
0x00000000, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x00000121, 0x000000F6, 0x000000F7, 0x0000011D, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x0000016D, 0x0000015D, 0x000002D9
|
||||
};
|
||||
|
||||
const uniChar_t TableIso8859_4[] = {
|
||||
const uint32_t TableIso8859_4[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -88,7 +88,7 @@ extern "C" {
|
||||
0x00000111, 0x00000146, 0x0000014D, 0x00000137, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x00000173, 0x000000FA, 0x000000FB, 0x000000FC, 0x00000169, 0x0000016B, 0x000002D9
|
||||
};
|
||||
|
||||
const uniChar_t TableIso8859_5[] = {
|
||||
const uint32_t TableIso8859_5[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -107,7 +107,7 @@ extern "C" {
|
||||
0x00002116, 0x00000451, 0x00000452, 0x00000453, 0x00000454, 0x00000455, 0x00000456, 0x00000457, 0x00000458, 0x00000459, 0x0000045A, 0x0000045B, 0x0000045C, 0x000000A7, 0x0000045E, 0x0000045F
|
||||
};
|
||||
|
||||
const uniChar_t TableIso8859_6[] = {
|
||||
const uint32_t TableIso8859_6[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -126,7 +126,7 @@ extern "C" {
|
||||
0x00000650, 0x00000651, 0x00000652, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
|
||||
};
|
||||
|
||||
const uniChar_t TableIso8859_7[] = {
|
||||
const uint32_t TableIso8859_7[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -145,7 +145,7 @@ extern "C" {
|
||||
0x000003C0, 0x000003C1, 0x000003C2, 0x000003C3, 0x000003C4, 0x000003C5, 0x000003C6, 0x000003C7, 0x000003C8, 0x000003C9, 0x000003CA, 0x000003CB, 0x000003CC, 0x000003CD, 0x000003CE, 0x00000000
|
||||
};
|
||||
|
||||
const uniChar_t TableIso8859_8[] = {
|
||||
const uint32_t TableIso8859_8[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -164,7 +164,7 @@ extern "C" {
|
||||
0x000005E0, 0x000005E1, 0x000005E2, 0x000005E3, 0x000005E4, 0x000005E5, 0x000005E6, 0x000005E7, 0x000005E8, 0x000005E9, 0x000005EA, 0x00000000, 0x00000000, 0x0000200E, 0x0000200F, 0x000003C0
|
||||
};
|
||||
|
||||
const uniChar_t TableIso8859_9[] = {
|
||||
const uint32_t TableIso8859_9[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -183,7 +183,7 @@ extern "C" {
|
||||
0x0000011F, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x00000131, 0x0000015F, 0x000000FF
|
||||
};
|
||||
|
||||
const uniChar_t TableIso8859_10[] = {
|
||||
const uint32_t TableIso8859_10[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -202,7 +202,7 @@ extern "C" {
|
||||
0x000000F0, 0x00000146, 0x0000014D, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x00000169, 0x000000F8, 0x00000173, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x000000FE, 0x00000138
|
||||
};
|
||||
|
||||
const uniChar_t TableIso8859_11[] = {
|
||||
const uint32_t TableIso8859_11[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -221,7 +221,7 @@ extern "C" {
|
||||
0x00000E50, 0x00000E51, 0x00000E52, 0x00000E53, 0x00000E54, 0x00000E55, 0x00000E56, 0x00000E57, 0x00000E58, 0x00000E59, 0x00000E5A, 0x00000E5B, 0x000006C0, 0x000006C0, 0x000006C0, 0x000006C0
|
||||
};
|
||||
|
||||
const uniChar_t TableIso8859_13[] = {
|
||||
const uint32_t TableIso8859_13[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -240,7 +240,7 @@ extern "C" {
|
||||
0x00000161, 0x00000144, 0x00000146, 0x000000F3, 0x0000014D, 0x000000F5, 0x000000F6, 0x000000F7, 0x00000173, 0x00000142, 0x0000015B, 0x0000016B, 0x000000FC, 0x0000017C, 0x0000017E, 0x00002019
|
||||
};
|
||||
|
||||
const uniChar_t TableIso8859_14[] = {
|
||||
const uint32_t TableIso8859_14[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
@ -259,7 +259,7 @@ extern "C" {
|
||||
0x00000175, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x00001E6B, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x00000177, 0x000000FF
|
||||
};
|
||||
|
||||
const uniChar_t TableIso8859_15[] = {
|
||||
const uint32_t TableIso8859_15[] = {
|
||||
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
|
||||
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
|
||||
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
|
||||
|
@ -13,20 +13,20 @@
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern const uniChar_t TableIso8859_1[];
|
||||
extern const uniChar_t TableIso8859_2[];
|
||||
extern const uniChar_t TableIso8859_3[];
|
||||
extern const uniChar_t TableIso8859_4[];
|
||||
extern const uniChar_t TableIso8859_5[];
|
||||
extern const uniChar_t TableIso8859_6[];
|
||||
extern const uniChar_t TableIso8859_7[];
|
||||
extern const uniChar_t TableIso8859_8[];
|
||||
extern const uniChar_t TableIso8859_9[];
|
||||
extern const uniChar_t TableIso8859_10[];
|
||||
extern const uniChar_t TableIso8859_11[];
|
||||
extern const uniChar_t TableIso8859_13[];
|
||||
extern const uniChar_t TableIso8859_14[];
|
||||
extern const uniChar_t TableIso8859_15[];
|
||||
extern const uint32_t TableIso8859_1[];
|
||||
extern const uint32_t TableIso8859_2[];
|
||||
extern const uint32_t TableIso8859_3[];
|
||||
extern const uint32_t TableIso8859_4[];
|
||||
extern const uint32_t TableIso8859_5[];
|
||||
extern const uint32_t TableIso8859_6[];
|
||||
extern const uint32_t TableIso8859_7[];
|
||||
extern const uint32_t TableIso8859_8[];
|
||||
extern const uint32_t TableIso8859_9[];
|
||||
extern const uint32_t TableIso8859_10[];
|
||||
extern const uint32_t TableIso8859_11[];
|
||||
extern const uint32_t TableIso8859_13[];
|
||||
extern const uint32_t TableIso8859_14[];
|
||||
extern const uint32_t TableIso8859_15[];
|
||||
|
||||
;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ def Create(target):
|
||||
'etk/unicode.cpp',
|
||||
'etk/unicodeTable.cpp',
|
||||
'etk/Char.cpp',
|
||||
'etk/UniChar.cpp',
|
||||
'etk/UString.cpp',
|
||||
'etk/Stream.cpp',
|
||||
'etk/RegExp.cpp',
|
||||
|
Loading…
x
Reference in New Issue
Block a user