PITimer important fix! ASCII-art start ...
git-svn-id: svn://db.shs.com.ru/pip@94 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -36,10 +36,79 @@ char * __sysoemname__ = 0;
|
||||
|
||||
|
||||
PIChar::PIChar(const char * c) {
|
||||
#ifdef PIP_ICU
|
||||
UErrorCode e((UErrorCode)0);
|
||||
UConverter * cc = ucnv_open(__syslocname__, &e);
|
||||
if (cc) {
|
||||
UChar uc;
|
||||
e = (UErrorCode)0;
|
||||
ucnv_toUChars(cc, &uc, 1, c, 4, &e);
|
||||
ucnv_close(cc);
|
||||
ch = uc;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
ch = *reinterpret_cast<const int * >(c);
|
||||
}
|
||||
|
||||
|
||||
PIChar PIChar::fromConsole(char c) {
|
||||
PIChar ret;
|
||||
#ifdef PIP_ICU
|
||||
UErrorCode e((UErrorCode)0);
|
||||
UConverter * cc = ucnv_open(__sysoemname__, &e);
|
||||
if (cc) {
|
||||
UChar uc;
|
||||
e = (UErrorCode)0;
|
||||
ucnv_toUChars(cc, &uc, 1, &c, 1, &e);
|
||||
ucnv_close(cc);
|
||||
ret.ch = uc;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
ret.ch = c;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
PIChar PIChar::fromSystem(char c) {
|
||||
PIChar ret;
|
||||
#ifdef PIP_ICU
|
||||
UErrorCode e((UErrorCode)0);
|
||||
UConverter * cc = ucnv_open(__syslocname__, &e);
|
||||
if (cc) {
|
||||
UChar uc;
|
||||
e = (UErrorCode)0;
|
||||
ucnv_toUChars(cc, &uc, 1, &c, 1, &e);
|
||||
ucnv_close(cc);
|
||||
ret.ch = uc;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
ret.ch = c;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
PIChar PIChar::fromUTF8(const char * c) {
|
||||
PIChar ret;
|
||||
#ifdef PIP_ICU
|
||||
UErrorCode e((UErrorCode)0);
|
||||
UConverter * cc = ucnv_open("UTF-8", &e);
|
||||
if (cc) {
|
||||
UChar uc;
|
||||
e = (UErrorCode)0;
|
||||
ucnv_toUChars(cc, &uc, 1, c, 8, &e);
|
||||
ucnv_close(cc);
|
||||
ret.ch = uc;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
ret.ch = *(ushort*)c;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
bool PIChar::operator ==(const PIChar & o) const {
|
||||
return strcmp(o.toCharPtr(), toCharPtr()) == 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user