diff --git a/libs/main/core/pichar.cpp b/libs/main/core/pichar.cpp index e7f5a9c6..a353a27b 100644 --- a/libs/main/core/pichar.cpp +++ b/libs/main/core/pichar.cpp @@ -35,12 +35,6 @@ char * __utf8name__ = 0; # include #endif #include -#ifdef ANDROID -# if __ANDROID_API__ < 21 -# define wctomb(s, wc) wcrtomb(s, wc, NULL) -# define mbtowc(pwc, s, n) mbrtowc(pwc, s, n, NULL) -# endif -#endif //! \addtogroup Core //! \{ @@ -86,9 +80,10 @@ ushort charFromCodepage(const char * c, int size, const char * codepage, int * t if (taken) *taken = ret; return buffer; # else - wchar_t wc(0); - mbtowc(0, 0, 0); // reset mbtowc - ret = mbtowc(&wc, c, size); + mbstate_t state; + memset(&state, 0, sizeof(state)); + wchar_t wc; + ret = mbrtowc(&wc, c, size, &state); //printf("mbtowc = %d\n", ret); if (ret < 1) return 0; return ushort(wc); @@ -387,15 +382,9 @@ PICout operator <<(PICout s, const PIChar & v) { } else #endif #ifdef WINDOWS - s << v.toSystem(); + s << v.toSystem(); #else - { - char tc[8]; - wctomb(0, 0); - int sz = wctomb(tc, v.ch); - for (int b = 0; b < sz; ++b) - s << tc[b]; - } + s << PIString(v); #endif } s.restoreControl(); diff --git a/libs/main/core/pistring.cpp b/libs/main/core/pistring.cpp index 00d6ac29..521b7d35 100644 --- a/libs/main/core/pistring.cpp +++ b/libs/main/core/pistring.cpp @@ -236,17 +236,6 @@ void PIString::appendFromChars(const char * c, int s, const char * codepage) { mbsrtowcs(&wstr[0], &c, len+1, &state); resize(len); for (int i=0; i 0) { -// //qDebug() << "0" << s; -//// sz = mbrtowc(&wc, c, s, &state); -// //qDebug() << "1" << sz; -//// if (sz < 1) break; -// push_back(PIChar(wc)); -// c += sz; s -= sz; -// //qDebug() << "2" << c; -// } // //qDebug() << "FromChars done" << size(); # endif #endif