diff --git a/libs/main/core/pistring.cpp b/libs/main/core/pistring.cpp index 521b7d35..8ac3c188 100644 --- a/libs/main/core/pistring.cpp +++ b/libs/main/core/pistring.cpp @@ -205,17 +205,18 @@ void PIString::appendFromChars(const char * c, int s, const char * codepage) { UErrorCode e((UErrorCode)0); UConverter * cc = ucnv_open(codepage, &e); if (cc) { - UChar * ucs = new UChar[s]; - memset(ucs, 0, s * sizeof(UChar)); + resize(s); +// UChar * ucs = new UChar[s]; +// memset(ucs, 0, s * sizeof(UChar)); e = (UErrorCode)0; - sz = ucnv_toUChars(cc, ucs, s, c, s, &e); + sz = ucnv_toUChars(cc, (UChar*)(PIDeque::data()), s, c, s, &e); //printf("appendFromChars %d -> %d\n", s, sz); //printf("PIString %d -> %d\n", c[0], ucs[0]); - reserve(size_s() + sz); - for (int i = 0; i < sz; ++i) { - push_back(PIChar((ushort)ucs[i])); - } - delete[] ucs; + resize(sz); +// for (int i = 0; i < sz; ++i) { +// push_back(PIChar((ushort)ucs[i])); +// } +// delete[] ucs; ucnv_close(cc); return; } @@ -332,21 +333,24 @@ void PIString::buildData(const char * cp) const { UErrorCode e((UErrorCode)0); UConverter * cc = ucnv_open(cp, &e); if (cc) { - char uc[8]; - data_.reserve(size_s()); - for (int i = 0; i < size_s(); ++i) { - if (at(i).isAscii()) { - data_.push_back(uchar(at(i).unicode16Code())); - } else { - e = (UErrorCode)0; - sz = ucnv_fromUChars(cc, uc, 8, (const UChar*)(PIDeque::data(i)), 1, &e); - for (int j = 0; j < sz; ++j) { - data_.push_back(uc[j]); - } - } - } + const size_t len = MB_CUR_MAX*size()+1; + data_ = (char *)malloc(len); + sz = ucnv_fromUChars(cc, data_, len, (const UChar*)(PIDeque::data()), size_s(), &e); +// char uc[8]; +// data_.reserve(size_s()); +// for (int i = 0; i < size_s(); ++i) { +// if (at(i).isAscii()) { +// data_.push_back(uchar(at(i).unicode16Code())); +// } else { +// e = (UErrorCode)0; +// for (int j = 0; j < sz; ++j) { +// data_.push_back(uc[j]); +// } +// } +// } ucnv_close(cc); - data_.push_back('\0'); + data_[sz] = '\0'; +// data_.push_back('\0'); return; } #else diff --git a/libs/main/system/piprocess.cpp b/libs/main/system/piprocess.cpp index 6faf7b5e..a8ba7251 100644 --- a/libs/main/system/piprocess.cpp +++ b/libs/main/system/piprocess.cpp @@ -205,7 +205,7 @@ void PIProcess::startProc(bool detached) { if (execve(str.data(), (char * const *)argscc, (char * const *)envcc) < 0) piCoutObj << "\"execve" << str << args << "\" error :" << errorString(); } else { - piMinSleep; + piMinSleep(); //cout << "wait" << endl; if (!detached) { wait(&exit_code);