git-svn-id: svn://db.shs.com.ru/pip@911 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
14
main.cpp
14
main.cpp
@@ -3,19 +3,21 @@
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
//piCout << __sysoemname__;
|
//piCout << __sysoemname__;
|
||||||
/*const char * s = "Eng, Русский №!123";
|
const char * s = "Eng, Русский №!123";
|
||||||
PIString str = PIString::fromUTF8(s);
|
PIString str = PIString::fromUTF8(s);
|
||||||
piCout << str.size() << str;
|
piCout << str;
|
||||||
str.forEach([](PIChar c){piCout << c; return c;});
|
piCout << str.toLowerCase();
|
||||||
|
piCout << str.toUpperCase();
|
||||||
|
/*str.forEach([](PIChar c){piCout << c; return c;});
|
||||||
PIFile f("1.txt", PIIODevice::ReadWrite);
|
PIFile f("1.txt", PIIODevice::ReadWrite);
|
||||||
f.clear();
|
f.clear();
|
||||||
f << str;*/
|
f << str;
|
||||||
PIChar c = PIChar::fromUTF8("│");
|
PIChar c = PIChar::fromUTF8("│");
|
||||||
PIString s = PIString::fromUTF8("│");
|
PIString s = PIString::fromUTF8("│");
|
||||||
piCout << c.unicode16Code() << s[0].unicode16Code();
|
piCout << c.unicode16Code() << s[0].unicode16Code();
|
||||||
piCout << c << s;
|
piCout << c << s << PISystemInfo::machineKey();
|
||||||
PIFile f("1.txt", PIIODevice::ReadWrite);
|
PIFile f("1.txt", PIIODevice::ReadWrite);
|
||||||
f.clear();
|
f.clear();
|
||||||
f << c;
|
f << c;*/
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
# include <stringapiset.h>
|
# include <stringapiset.h>
|
||||||
|
# include <winnls.h>
|
||||||
#endif
|
#endif
|
||||||
char * __syslocname__ = 0;
|
char * __syslocname__ = 0;
|
||||||
char * __sysoemname__ = 0;
|
char * __sysoemname__ = 0;
|
||||||
@@ -86,6 +87,20 @@ ushort charFromCodepage(const char * c, int size, const char * codepage, int * t
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int charCompare(const ushort * f, const ushort * s) {
|
||||||
|
return
|
||||||
|
#ifdef PIP_ICU
|
||||||
|
u_strCompare((const UChar*)f, 1, (const UChar*)s, 1, FALSE);
|
||||||
|
#else
|
||||||
|
# ifdef WINDOWS
|
||||||
|
CompareStringW(LOCALE_USER_DEFAULT, 0, (PCNZWCH)f, 1, (PCNZWCH)s, 1);
|
||||||
|
# else
|
||||||
|
strcmp((const char *)f, (const char *)s);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
PIChar::PIChar(const char * c, int * bytes) {
|
PIChar::PIChar(const char * c, int * bytes) {
|
||||||
ch = charFromCodepage(c, 4, __syslocname__, bytes);
|
ch = charFromCodepage(c, 4, __syslocname__, bytes);
|
||||||
}
|
}
|
||||||
@@ -120,42 +135,22 @@ bool PIChar::operator ==(const PIChar & o) const {
|
|||||||
|
|
||||||
|
|
||||||
bool PIChar::operator >(const PIChar & o) const {
|
bool PIChar::operator >(const PIChar & o) const {
|
||||||
return
|
return charCompare(&ch, &(o.ch)) > 0;
|
||||||
#ifdef PIP_ICU
|
|
||||||
u_strCompare((const UChar*)&(ch), 1, (const UChar*)&(o.ch), 1, FALSE) > 0;
|
|
||||||
#else
|
|
||||||
strcmp(toCharPtr(), o.toCharPtr()) > 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIChar::operator <(const PIChar & o) const {
|
bool PIChar::operator <(const PIChar & o) const {
|
||||||
return
|
return charCompare(&ch, &(o.ch)) < 0;
|
||||||
#ifdef PIP_ICU
|
|
||||||
u_strCompare((const UChar*)&(ch), 1, (const UChar*)&(o.ch), 1, FALSE) < 0;
|
|
||||||
#else
|
|
||||||
strcmp(toCharPtr(), o.toCharPtr()) < 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIChar::operator >=(const PIChar & o) const {
|
bool PIChar::operator >=(const PIChar & o) const {
|
||||||
return
|
return charCompare(&ch, &(o.ch)) >= 0;
|
||||||
#ifdef PIP_ICU
|
|
||||||
u_strCompare((const UChar*)&(ch), 1, (const UChar*)&(o.ch), 1, FALSE) >= 0;
|
|
||||||
#else
|
|
||||||
strcmp(toCharPtr(), o.toCharPtr()) >= 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIChar::operator <=(const PIChar & o) const {
|
bool PIChar::operator <=(const PIChar & o) const {
|
||||||
return
|
return charCompare(&ch, &(o.ch)) <= 0;
|
||||||
#ifdef PIP_ICU
|
|
||||||
u_strCompare((const UChar*)&(ch), 1, (const UChar*)&(o.ch), 1, FALSE) <= 0;
|
|
||||||
#else
|
|
||||||
strcmp(toCharPtr(), o.toCharPtr()) <= 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -269,26 +264,34 @@ char PIChar::toSystem() const {
|
|||||||
|
|
||||||
|
|
||||||
PIChar PIChar::toUpper() const {
|
PIChar PIChar::toUpper() const {
|
||||||
|
if (isAscii()) return PIChar(toupper(ch));
|
||||||
#ifdef PIP_ICU
|
#ifdef PIP_ICU
|
||||||
UChar c(0);
|
UChar c(0);
|
||||||
UErrorCode e((UErrorCode)0);
|
UErrorCode e((UErrorCode)0);
|
||||||
u_strToUpper(&c, 1, (const UChar*)(&ch), 1, 0, &e);
|
u_strToUpper(&c, 1, (const UChar*)(&ch), 1, 0, &e);
|
||||||
return PIChar(c);
|
return PIChar(c);
|
||||||
#else
|
#else
|
||||||
return PIChar(toupper(ch));
|
ushort wc = 0;
|
||||||
|
if (LCMapStringW(LOCALE_USER_DEFAULT, LCMAP_UPPERCASE, (LPCWSTR)&ch, 1, (LPWSTR)&wc, 1) == 1)
|
||||||
|
return PIChar(wc);
|
||||||
#endif
|
#endif
|
||||||
|
return PIChar(toupper(ch));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIChar PIChar::toLower() const {
|
PIChar PIChar::toLower() const {
|
||||||
|
if (isAscii()) return PIChar(tolower(ch));
|
||||||
#ifdef PIP_ICU
|
#ifdef PIP_ICU
|
||||||
UChar c(0);
|
UChar c(0);
|
||||||
UErrorCode e((UErrorCode)0);
|
UErrorCode e((UErrorCode)0);
|
||||||
u_strToLower(&c, 1, (const UChar*)(&ch), 1, 0, &e);
|
u_strToLower(&c, 1, (const UChar*)(&ch), 1, 0, &e);
|
||||||
return PIChar(c);
|
return PIChar(c);
|
||||||
#else
|
#else
|
||||||
return PIChar(tolower(ch));
|
ushort wc = 0;
|
||||||
|
if (LCMapStringW(LOCALE_USER_DEFAULT, LCMAP_LOWERCASE, (LPCWSTR)&ch, 1, (LPWSTR)&wc, 1) == 1)
|
||||||
|
return PIChar(wc);
|
||||||
#endif
|
#endif
|
||||||
|
return PIChar(tolower(ch));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ PIString confDir() {
|
|||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
PIDir::home().path() + "/AppData/Local"
|
PIDir::home().path() + "/AppData/Local"
|
||||||
#elif defined(ANDROID)
|
#elif defined(ANDROID)
|
||||||
"/mnt/sdcard"
|
""
|
||||||
#else
|
#else
|
||||||
PIDir::home().path() + "/.config"
|
PIDir::home().path() + "/.config"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user