diff options
| author | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2016-04-13 20:14:41 +0000 |
|---|---|---|
| committer | vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f> | 2016-04-13 20:14:41 +0000 |
| commit | bf2e2632fa893c46f3880a890f5a4b4255c03d69 (patch) | |
| tree | a037da59234cd5e71ddeeb0d6d3237de1e1528f5 /src/VBox/Runtime/common/string/utf-16-case.cpp | |
| parent | 3e103f2ca55b90b3e096211a728d749d2da0ef72 (diff) | |
| download | VirtualBox-svn-bf2e2632fa893c46f3880a890f5a4b4255c03d69.tar.gz | |
IPRT: Added testcase for RTNtPathExpand8dot3Path and RTNtPathFindPossible8dot3Name, fixing bug in the former. include\ src\VBox\Runtime\
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@60481 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'src/VBox/Runtime/common/string/utf-16-case.cpp')
| -rw-r--r-- | src/VBox/Runtime/common/string/utf-16-case.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/VBox/Runtime/common/string/utf-16-case.cpp b/src/VBox/Runtime/common/string/utf-16-case.cpp index 800a24be3d3..c57ee86e9db 100644 --- a/src/VBox/Runtime/common/string/utf-16-case.cpp +++ b/src/VBox/Runtime/common/string/utf-16-case.cpp @@ -105,6 +105,45 @@ RTDECL(int) RTUtf16ICmp(register PCRTUTF16 pwsz1, register PCRTUTF16 pwsz2) RT_EXPORT_SYMBOL(RTUtf16ICmp); +RTDECL(int) RTUtf16ICmpUtf8(PCRTUTF16 pwsz1, const char *psz2) +{ + /* + * NULL and empty strings are all the same. + */ + if (!pwsz1) + return !psz2 || !*psz2 ? 0 : -1; + if (!psz2) + return !*pwsz1 ? 0 : 1; + + /* + * Compare with a UTF-8 string by enumerating them char by char. + */ + for (;;) + { + RTUNICP uc1; + int rc = RTUtf16GetCpEx(&pwsz1, &uc1); + AssertRCReturn(rc, 1); + + RTUNICP uc2; + rc = RTStrGetCpEx(&psz2, &uc2); + AssertRCReturn(rc, -1); + if (uc1 == uc2) + { + if (uc1) + continue; + return 0; + } + + if (RTUniCpToUpper(uc1) == RTUniCpToUpper(uc2)) + continue; + if (RTUniCpToLower(uc1) == RTUniCpToLower(uc2)) + continue; + return uc1 < uc2 ? -1 : 1; + } +} +RT_EXPORT_SYMBOL(RTUtf16CmpIUtf8); + + RTDECL(PRTUTF16) RTUtf16ToLower(PRTUTF16 pwsz) { PRTUTF16 pwc = pwsz; |
