git-svn-id: svn://db.shs.com.ru/pip@534 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5

This commit is contained in:
2017-08-09 20:12:36 +00:00
parent ae6d397e0e
commit 5dcc867689
5 changed files with 71 additions and 36 deletions

View File

@@ -21,6 +21,9 @@
#ifdef PIP_ICU
# include "unicode/ucnv.h"
#endif
//#ifdef ANDROID
# include <wchar.h>
//#endif
/*! \class PIString
* \brief String class
@@ -217,25 +220,7 @@ void PIString::appendFromChars(const char * c, int s, const char * cp) {
continue;
}
sz = mbtowc(&wc, &(c[i]), 4);
//cout << sz << endl;
switch (sz) {
case 4:
push_back(PIChar(*(int*)&(c[i])));
i += 3;
continue;
case 3:
push_back(PIChar(*(int*)&(c[i])));
back().ch &= 0xFFFFFF;
i += 2;
continue;
case 2:
push_back(PIChar(*(short * )&(c[i])));
++i;
continue;
default:
push_back(PIChar(c[i]));
break;
}
push_back(PIChar(int(wc)));
}
}
@@ -332,19 +317,28 @@ void PIString::buildData(const char * cp) const {
return;
}
#endif
uint wc;
uchar tc;
wchar_t wc;
char tc[4];
mbstate_t s;
int sz(0);
//printf("PIString::data %d\n", size_s());
for (int i = 0, j = 0; i < size_s(); ++i) {
wc = uint(at(i).unicode16Code());
for (int i = 0; i < size_s(); ++i) {
if (at(i).isAscii()) {
data_.push_back(uchar(at(i).toAscii()));
continue;
}
wc = at(i).toWChar();
sz = piClampi(wcrtomb(tc, wc, &s), 0, 4);
for (int b = 0; b < sz; ++b)
data_.push_back(uchar(tc[b]));
//printf("__%d_%d\n", i, wc);
tc = wc & 0xFF;
/*tc = wc & 0xFF;
while (tc) {
data_.push_back(uchar(tc)); ++j;
data_.push_back(uchar(tc));
wc >>= 8;
tc = wc & 0xFF;
//printf("____%d\n", wc);
}
}*/
/*if (at(i).isAscii())
data_.push_back(uchar(at(i).toAscii()));
else {
@@ -429,7 +423,7 @@ PIString & PIString::operator +=(const char * str) {
PIString & PIString::operator +=(const wchar_t * str) {
//cout << "wc" << endl;
int l = 0, sz;
/*int l = 0, sz;
char * c = new char[MB_CUR_MAX];
while (str[l] != 0) ++l;
for (int i = 0; i < l; ++i) {
@@ -450,7 +444,10 @@ PIString & PIString::operator +=(const wchar_t * str) {
break;
}
}
delete[] c;
delete[] c;*/
int i = -1;
while (str[++i])
push_back(PIChar(int(str[i])));
return *this;
}