author | llornkcor <llornkcor> | 2002-07-01 23:24:08 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-07-01 23:24:08 (UTC) |
commit | 59222a752fa4c8a1e8c2a00ee2f9e22855f12bb2 (patch) (side-by-side diff) | |
tree | f148d4858859dac3b413e675c760acfdab24b8e6 /noncore/apps/opie-reader/ustring.h | |
parent | c08be8ae22dcc1bfb83cfdec807149b161d770f5 (diff) | |
download | opie-59222a752fa4c8a1e8c2a00ee2f9e22855f12bb2.zip opie-59222a752fa4c8a1e8c2a00ee2f9e22855f12bb2.tar.gz opie-59222a752fa4c8a1e8c2a00ee2f9e22855f12bb2.tar.bz2 |
initial
Diffstat (limited to 'noncore/apps/opie-reader/ustring.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/ustring.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/ustring.h b/noncore/apps/opie-reader/ustring.h new file mode 100644 index 0000000..a4dc048 --- a/dev/null +++ b/noncore/apps/opie-reader/ustring.h @@ -0,0 +1,71 @@ +#include <qstring.h> + +#ifdef _UNICODE +inline size_t ustrlen(const tchar* _p) +{ + if (_p == NULL) return 0; + const tchar *p = _p; + while (*p != 0) + { + p++; +/* + if (p - _p == 20) + { + printf("ustrlen::String too long:"); + for (int i = 0; i < 20; i++) printf("%c",_p[i]); + printf("\n"); + } +*/ + } + return p - _p; +} + +inline int ustrcmp(const tchar* _p1, const tchar* _p2) +{ + if (_p1 == 0) return 1; + if (_p2 == 0) return -1; + const tchar* p1 = _p1, *p2 = _p2; + while (*p1 != 0) + { +/* + if (p1 - _p1 == 20) + { + printf("ustrcmp::String too long:"); + for (int i = 0; i < 20; i++) printf("%c",_p1[i]); + printf("\n"); + } +*/ + if (*p1 < *p2) return -1; + if (*p1 > *p2) return 1; + if (*p2 == 0) return 1; + p1++, p2++; + } + if (*p2 != 0) return -1; + return 0; +} + +inline QString toQString(tchar *_p) +{ + if (_p == NULL) return 0; + int i = 0; + tchar *p = _p; + QString ret; + while (*p != 0) ret[i++] = *(p++); + return ret; +} + +inline QString toQString(tchar *_p, unsigned int len) +{ + if (_p == NULL) return 0; + unsigned int i = 0; + tchar *p = _p; + QString ret; + while (*p != 0 && i < len) ret[i++] = *(p++); + return ret; +} +#else + +inline size_t ustrlen(const tchar* _p) { return strlen(_p); } +inline int ustrcmp(const tchar* _p1, const tchar* _p2) { return strcmp(_p1, _p2); } + +#endif |