summaryrefslogtreecommitdiff
path: root/src/VBox/Runtime/common/string/utf-16-case.cpp
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2016-04-13 20:14:41 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2016-04-13 20:14:41 +0000
commitbf2e2632fa893c46f3880a890f5a4b4255c03d69 (patch)
treea037da59234cd5e71ddeeb0d6d3237de1e1528f5 /src/VBox/Runtime/common/string/utf-16-case.cpp
parent3e103f2ca55b90b3e096211a728d749d2da0ef72 (diff)
downloadVirtualBox-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.cpp39
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;