From 6dff576888303e011fd73ca6661097fb752c47ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D0=B5=D0=BB=D0=B8=D0=BF=D0=B5=D0=BD=D0=BA=D0=BE=20?= =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Thu, 5 Mar 2020 21:14:28 +0000 Subject: [PATCH] git-svn-id: svn://db.shs.com.ru/pip@904 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5 --- main.cpp | 11 +++++++++-- src_main/console/piscreendrawer.cpp | 20 +++++++++++--------- src_main/core/pichar.cpp | 7 ++++--- src_main/core/piinit.cpp | 13 +++---------- src_main/core/piinit.h | 3 +-- src_main/core/pistring.cpp | 9 +++++---- 6 files changed, 33 insertions(+), 30 deletions(-) diff --git a/main.cpp b/main.cpp index 0fc283a4..5ed92458 100644 --- a/main.cpp +++ b/main.cpp @@ -3,12 +3,19 @@ int main() { //piCout << __sysoemname__; - const char * s = "Eng, Русский №!123"; + /*const char * s = "Eng, Русский №!123"; PIString str = PIString::fromUTF8(s); piCout << str.size() << str; str.forEach([](PIChar c){piCout << c; return c;}); PIFile f("1.txt", PIIODevice::ReadWrite); f.clear(); - f << str; + f << str;*/ + PIChar c = PIChar::fromUTF8("│"); + PIString s = PIString::fromUTF8("│"); + piCout << c.unicode16Code() << s[0].unicode16Code(); + piCout << c << s; + PIFile f("1.txt", PIIODevice::ReadWrite); + f.clear(); + f << c; return 0; } diff --git a/src_main/console/piscreendrawer.cpp b/src_main/console/piscreendrawer.cpp index 35f17a12..29df5992 100644 --- a/src_main/console/piscreendrawer.cpp +++ b/src_main/console/piscreendrawer.cpp @@ -19,69 +19,71 @@ #include "piscreendrawer.h" +// comment for use ascii instead of unicode symbols +#define USE_UNICODE using namespace PIScreenTypes; PIScreenDrawer::PIScreenDrawer(PIVector > & c): cells(c) { arts_[LineVertical] = -#ifdef PIP_ICU +#ifdef USE_UNICODE PIChar::fromUTF8("│"); #else PIChar('|'); #endif arts_[LineHorizontal] = -#ifdef PIP_ICU +#ifdef USE_UNICODE PIChar::fromUTF8("─"); #else PIChar('-'); #endif arts_[Cross] = -#ifdef PIP_ICU +#ifdef USE_UNICODE PIChar::fromUTF8("┼"); #else PIChar('+'); #endif arts_[CornerTopLeft] = -#ifdef PIP_ICU +#ifdef USE_UNICODE PIChar::fromUTF8("┌"); #else PIChar('+'); #endif arts_[CornerTopRight] = -#ifdef PIP_ICU +#ifdef USE_UNICODE PIChar::fromUTF8("┐"); #else PIChar('+'); #endif arts_[CornerBottomLeft] = -#ifdef PIP_ICU +#ifdef USE_UNICODE PIChar::fromUTF8("└"); #else PIChar('+'); #endif arts_[CornerBottomRight] = -#ifdef PIP_ICU +#ifdef USE_UNICODE PIChar::fromUTF8("┘"); #else PIChar('+'); #endif arts_[Unchecked] = -#ifdef PIP_ICU +#ifdef USE_UNICODE PIChar::fromUTF8("☐"); #else PIChar('O'); #endif arts_[Checked] = -#ifdef PIP_ICU +#ifdef USE_UNICODE PIChar::fromUTF8("☑"); #else PIChar('0'); diff --git a/src_main/core/pichar.cpp b/src_main/core/pichar.cpp index 7a283e5e..e754d0a8 100644 --- a/src_main/core/pichar.cpp +++ b/src_main/core/pichar.cpp @@ -53,15 +53,16 @@ char * __utf8name__ = 0; ushort charFromCodepage(const char * c, int size, const char * codepage, int * taken = 0) { if (!c || size <= 0) return 0; - if (c[0] < 0x80) return c[0]; + if (uchar(c[0]) < 0x80) return c[0]; int ret; #ifdef PIP_ICU UErrorCode e((UErrorCode)0); UConverter * cc = ucnv_open(codepage, &e); if (cc) { - UChar uc; + UChar uc(0); e = (UErrorCode)0; ret = ucnv_toUChars(cc, &uc, 1, c, size, &e); + //printf("PIChar %d -> %d\n", c[0], uc); if (taken) *taken = ret; ucnv_close(cc); return ushort(uc); @@ -296,7 +297,7 @@ PICout operator <<(PICout s, const PIChar & v) { s.setControl(0, true); #ifdef PIP_ICU UErrorCode e((UErrorCode)0); - UConverter * cc = ucnv_open(PICout::isBufferActive() ? __syslocname__ : __sysoemname__, &e); + UConverter * cc = ucnv_open(__syslocname__, &e); if (cc) { char uc[8]; memset(uc, 0, 8); diff --git a/src_main/core/piinit.cpp b/src_main/core/piinit.cpp index f67e8d5b..e3f5551e 100644 --- a/src_main/core/piinit.cpp +++ b/src_main/core/piinit.cpp @@ -362,14 +362,8 @@ bool PIInit::isBuildOptionEnabled(PIInit::BuildOption o) { #else false; #endif - case IntrospectionContainers: return -#ifdef PIP_INTROSPECTION_CONTAINERS - true; -#else - false; -#endif - case IntrospectionThreads: return -#ifdef PIP_INTROSPECTION_THREADS + case Introspection: return +#ifdef PIP_INTROSPECTION true; #else false; @@ -404,8 +398,7 @@ PIStringList PIInit::buildOptions() { if (isBuildOptionEnabled(USB)) ret << "USB"; if (isBuildOptionEnabled(STL)) ret << "STL"; if (isBuildOptionEnabled(Crypt)) ret << "Crypt"; - if (isBuildOptionEnabled(IntrospectionContainers)) ret << "IntrospectionContainers"; - if (isBuildOptionEnabled(IntrospectionThreads)) ret << "IntrospectionThreads"; + if (isBuildOptionEnabled(Introspection)) ret << "Introspection"; if (isBuildOptionEnabled(FFTW)) ret << "FFTW"; if (isBuildOptionEnabled(Compress)) ret << "Compress"; if (isBuildOptionEnabled(OpenCL)) ret << "OpenCL"; diff --git a/src_main/core/piinit.h b/src_main/core/piinit.h index f01b0da1..a1ebe85e 100644 --- a/src_main/core/piinit.h +++ b/src_main/core/piinit.h @@ -51,8 +51,7 @@ public: USB /*! USB support */ = 0x02, STL /*! STL containers implementation */ = 0x04, Crypt /*! Crypt support */ = 0x08, - IntrospectionContainers /*! Containers introspection */ = 0x010, - IntrospectionThreads /*! Threads introspection */ = 0x20, + Introspection /*! Introspection */ = 0x010, FFTW /*! FFTW3 support */ = 0x40, Compress /*! Zlib compression support */ = 0x80, OpenCL /*! OpenCL support */ = 0x100, diff --git a/src_main/core/pistring.cpp b/src_main/core/pistring.cpp index 82bd257d..5154a189 100755 --- a/src_main/core/pistring.cpp +++ b/src_main/core/pistring.cpp @@ -206,18 +206,19 @@ llong PIString::toNumberBase(const PIString & value, int base, bool * ok) { } -void PIString::appendFromChars(const char * c, int s, const char * cp) { +void PIString::appendFromChars(const char * c, int s, const char * codepage) { if (s <= 0) return; int sz; #ifdef PIP_ICU UErrorCode e((UErrorCode)0); - UConverter * cc = ucnv_open(cp, &e); + UConverter * cc = ucnv_open(codepage, &e); if (cc) { UChar * ucs = new UChar[s]; memset(ucs, 0, s * sizeof(UChar)); e = (UErrorCode)0; int sz = ucnv_toUChars(cc, ucs, s, c, s, &e); //printf("appendFromChars %d -> %d\n", s, sz); + //printf("PIString %d -> %d\n", c[0], ucs[0]); for (int i = 0; i < sz; ++i) push_back(PIChar(ucs[i])); delete[] ucs; @@ -226,10 +227,10 @@ void PIString::appendFromChars(const char * c, int s, const char * cp) { } #else # ifdef WINDOWS - sz = MultiByteToWideChar((uint)(uintptr_t)cp, MB_ERR_INVALID_CHARS, c, s, 0, 0); + sz = MultiByteToWideChar((uint)(uintptr_t)codepage, MB_ERR_INVALID_CHARS, c, s, 0, 0); if (sz <= 0) return; wchar_t * buffer = new wchar_t[sz]; - MultiByteToWideChar((uint)(uintptr_t)cp, MB_ERR_INVALID_CHARS, c, s, buffer, sz); + MultiByteToWideChar((uint)(uintptr_t)codepage, MB_ERR_INVALID_CHARS, c, s, buffer, sz); for (int i = 0; i < sz; ++i) push_back(PIChar((ushort)buffer[i])); delete[] buffer;