PIString/PIChar explicit, support char16_t
This commit is contained in:
@@ -90,7 +90,7 @@ int charCompare(const PIChar & f, const PIChar & s) {
|
||||
if (f.isAscii() && s.isAscii()) return strncmp(f.toCharPtr(), s.toCharPtr(), 1);
|
||||
return
|
||||
#ifdef PIP_ICU
|
||||
u_strCompare((const UChar *)f.toWCharPtr(), 1, (const UChar *)s.toWCharPtr(), 1, 0);
|
||||
u_strCompare((const UChar *)f.toWCharPtr(), 1, (const UChar *)s.toWCharPtr(), 1, 0);
|
||||
#else
|
||||
# ifdef WINDOWS
|
||||
CompareStringW(LOCALE_USER_DEFAULT, 0, (PCNZWCH)f.toWCharPtr(), 1, (PCNZWCH)s.toWCharPtr(), 1) - 2;
|
||||
@@ -111,11 +111,6 @@ bool winIsCharType(const ushort * ch, int type) {
|
||||
}
|
||||
|
||||
|
||||
PIChar::PIChar(const char * c, int * bytes) {
|
||||
ch = charFromCodepage(c, 4, __syslocname__, bytes);
|
||||
}
|
||||
|
||||
|
||||
PIChar PIChar::fromConsole(char c) {
|
||||
PIChar ret;
|
||||
ret.ch = charFromCodepage(&c, 1, __sysoemname__);
|
||||
@@ -130,10 +125,20 @@ PIChar PIChar::fromSystem(char c) {
|
||||
}
|
||||
|
||||
|
||||
PIChar PIChar::fromSystem(const char * c) {
|
||||
PIChar ret;
|
||||
int l = 0;
|
||||
while (c[l] != '\0' && l < 4)
|
||||
++l;
|
||||
ret.ch = charFromCodepage(c, l, __syslocname__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
PIChar PIChar::fromUTF8(const char * c) {
|
||||
PIChar ret;
|
||||
int l = 0;
|
||||
while (c[l] != '\0')
|
||||
while (c[l] != '\0' && l < 4)
|
||||
++l;
|
||||
ret.ch = charFromCodepage(c, l, __utf8name__);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user