summaryrefslogtreecommitdiff
path: root/src/VBox/Runtime/common/string/utf-8-case.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/Runtime/common/string/utf-8-case.cpp')
-rw-r--r--src/VBox/Runtime/common/string/utf-8-case.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/VBox/Runtime/common/string/utf-8-case.cpp b/src/VBox/Runtime/common/string/utf-8-case.cpp
index 7a0bf2eb..e674944f 100644
--- a/src/VBox/Runtime/common/string/utf-8-case.cpp
+++ b/src/VBox/Runtime/common/string/utf-8-case.cpp
@@ -338,3 +338,82 @@ RTDECL(char *) RTStrToUpper(char *psz)
}
RT_EXPORT_SYMBOL(RTStrToUpper);
+
+RTDECL(bool) RTStrIsCaseFoldable(const char *psz)
+{
+ /*
+ * Loop the code points in the string, checking them one by one until we
+ * find something that can be folded.
+ */
+ RTUNICP uc;
+ do
+ {
+ int rc = RTStrGetCpEx(&psz, &uc);
+ if (RT_SUCCESS(rc))
+ {
+ if (RTUniCpIsFoldable(uc))
+ return true;
+ }
+ else
+ {
+ /* bad encoding, just skip it quietly (uc == RTUNICP_INVALID (!= 0)). */
+ AssertRC(rc);
+ }
+ } while (uc != 0);
+
+ return false;
+}
+RT_EXPORT_SYMBOL(RTStrIsCaseFoldable);
+
+
+RTDECL(bool) RTStrIsUpperCased(const char *psz)
+{
+ /*
+ * Check that there are no lower case chars in the string.
+ */
+ RTUNICP uc;
+ do
+ {
+ int rc = RTStrGetCpEx(&psz, &uc);
+ if (RT_SUCCESS(rc))
+ {
+ if (RTUniCpIsLower(uc))
+ return false;
+ }
+ else
+ {
+ /* bad encoding, just skip it quietly (uc == RTUNICP_INVALID (!= 0)). */
+ AssertRC(rc);
+ }
+ } while (uc != 0);
+
+ return true;
+}
+RT_EXPORT_SYMBOL(RTStrIsUpperCased);
+
+
+RTDECL(bool) RTStrIsLowerCased(const char *psz)
+{
+ /*
+ * Check that there are no lower case chars in the string.
+ */
+ RTUNICP uc;
+ do
+ {
+ int rc = RTStrGetCpEx(&psz, &uc);
+ if (RT_SUCCESS(rc))
+ {
+ if (RTUniCpIsUpper(uc))
+ return false;
+ }
+ else
+ {
+ /* bad encoding, just skip it quietly (uc == RTUNICP_INVALID (!= 0)). */
+ AssertRC(rc);
+ }
+ } while (uc != 0);
+
+ return true;
+}
+RT_EXPORT_SYMBOL(RTStrIsLowerCased);
+