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

This commit is contained in:
2020-03-05 21:14:28 +00:00
parent 45137053ff
commit 6dff576888
6 changed files with 33 additions and 30 deletions

View File

@@ -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;
}

View File

@@ -19,69 +19,71 @@
#include "piscreendrawer.h"
// comment for use ascii instead of unicode symbols
#define USE_UNICODE
using namespace PIScreenTypes;
PIScreenDrawer::PIScreenDrawer(PIVector<PIVector<Cell> > & 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');

View File

@@ -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);

View File

@@ -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";

View File

@@ -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,

View File

@@ -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;