git-svn-id: svn://db.shs.com.ru/pip@904 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user