diff --git a/src_main/console/piscreentiles.cpp b/src_main/console/piscreentiles.cpp index 2b0f0b08..fa398268 100644 --- a/src_main/console/piscreentiles.cpp +++ b/src_main/console/piscreentiles.cpp @@ -700,7 +700,13 @@ bool TileInput::keyEvent(PIKbdListener::KeyEvent key) { case PIKbdListener::F12: break; default: - text.insert(cur, PIChar(key.key)); + PIChar tc +#ifdef WINDOWS + = PIChar(key.key); +#else + = PIChar::fromUTF8((char *)&(key.key)); +#endif + text.insert(cur, tc); cur++; oo++; if (cur - offset >= lwid - osp) offset += oo; diff --git a/src_main/core/pichar.cpp b/src_main/core/pichar.cpp index 2ff8156e..78c4d880 100644 --- a/src_main/core/pichar.cpp +++ b/src_main/core/pichar.cpp @@ -20,8 +20,7 @@ along with this program. If not, see . */ -#include -#include +#include "piincludes_p.h" #include "pibytearray.h" #ifdef PIP_ICU # include "unicode/ucnv.h" @@ -115,9 +114,13 @@ PIChar PIChar::fromUTF8(const char * c) { #endif //#ifdef ANDROID wchar_t wc(0); - mbstate_t s; - mbrtowc(&wc, c, 4, &s); - ret.ch = wc; + mbtowc(0, 0, 0); // reset mbtowc + //mbstate_t s; + //mbrtowc(&wc, c, 4, &s); + int sz = 0; + sz = mbtowc(&wc, c, sizeof(ushort)); + if (sz < 1 || sz > (int)sizeof(ushort)) ret.ch = 0; + else ret.ch = wc; return ret; //#endif // ret.ch = *(ushort*)c; diff --git a/src_main/core/pistring.cpp b/src_main/core/pistring.cpp index f6a85127..6774e51e 100755 --- a/src_main/core/pistring.cpp +++ b/src_main/core/pistring.cpp @@ -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); diff --git a/src_main/piversion.h b/src_main/piversion.h index 81022238..814ca432 100644 --- a/src_main/piversion.h +++ b/src_main/piversion.h @@ -4,7 +4,7 @@ #define PIP_VERSION_MAJOR 1 #define PIP_VERSION_MINOR 1 -#define PIP_VERSION_REVISION 0 +#define PIP_VERSION_REVISION 1 #define PIP_VERSION_SUFFIX "" #endif // PIVERSION_H