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

This commit is contained in:
2017-11-20 14:32:19 +00:00
parent a1b95e6e66
commit 9f2c55de5b
4 changed files with 27 additions and 16 deletions

View File

@@ -214,13 +214,12 @@ void PIString::appendFromChars(const char * c, int s, const char * cp) {
#endif
int sz;
wchar_t wc;
for (int i = 0; i < s; ++i) {
if (/*isascii(c[i])*/c[i] >= 0) {
push_back(PIChar(c[i]));
continue;
}
sz = mbtowc(&wc, &(c[i]), 4);
mbtowc(0,0,0); // reset mbtowc
while (s>0) {
sz = mbtowc(&wc, c, s);
if (sz < 1) break;
push_back(PIChar(int(wc)));
c += sz; s -= sz;
}
}
@@ -330,8 +329,10 @@ void PIString::buildData(const char * cp) const {
}
#endif
wchar_t wc;
char tc[4];
mbstate_t s;
char tc[8];
// mbstate_t s;
// mbrlen(0,0,&s);
wctomb(0, 0);
int sz(0);
//printf("PIString::data %d\n", size_s());
for (int i = 0; i < size_s(); ++i) {
@@ -340,7 +341,8 @@ void PIString::buildData(const char * cp) const {
continue;
}
wc = at(i).toWChar();
sz = piClampi(wcrtomb(tc, wc, &s), 0, 4);
// sz = piClampi(wcrtomb(tc, wc, &s), 0, 4);
sz = wctomb(tc, wc);
for (int b = 0; b < sz; ++b)
data_.push_back(uchar(tc[b]));
//printf("__%d_%d\n", i, wc);