summaryrefslogtreecommitdiff
path: root/include/iprt/uni.h
diff options
context:
space:
mode:
authorvboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2014-07-01 18:14:02 +0000
committervboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>2014-07-01 18:14:02 +0000
commitee5613d11197bbf4354c98cbf15f8eeb9f38ff88 (patch)
tree47ab82c145351b84edc00a642e6ed1fdc21ad291 /include/iprt/uni.h
parent4fe2f225465f17c37cdbeddc623ad66a816ee7a5 (diff)
downloadVirtualBox-svn-ee5613d11197bbf4354c98cbf15f8eeb9f38ff88.tar.gz
Merged in iprt++ dev branch.
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@51770 cfe28804-0f27-0410-a406-dd0f0b0b656f
Diffstat (limited to 'include/iprt/uni.h')
-rw-r--r--include/iprt/uni.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/include/iprt/uni.h b/include/iprt/uni.h
index a1161db1ad2..0ffdc631872 100644
--- a/include/iprt/uni.h
+++ b/include/iprt/uni.h
@@ -417,6 +417,59 @@ DECLINLINE(RTUNICP) RTUniCpToLower(RTUNICP CodePoint)
RTDECL(void) RTUniFree(PRTUNICP pusz);
+/**
+ * Checks if a code point valid.
+ *
+ * Any code point (defined or not) within the 17 unicode planes (0 thru 16),
+ * except surrogates will be considered valid code points by this function.
+ *
+ * @returns true if in range, false if not.
+ * @param CodePoint The unicode code point to validate.
+ */
+DECLINLINE(bool) RTUniCpIsValid(RTUNICP CodePoint)
+{
+ return CodePoint <= 0x00d7ff
+ || ( CodePoint <= 0x10ffff
+ && CodePoint >= 0x00e000);
+}
+
+
+/**
+ * Checks if the given code point is in the BMP range.
+ *
+ * Surrogates are not considered in the BMP range by this function.
+ *
+ * @returns true if in BMP, false if not.
+ * @param CodePoint The unicode code point to consider.
+ */
+DECLINLINE(bool) RTUniCpIsBMP(RTUNICP CodePoint)
+{
+ return CodePoint <= 0xd7ff
+ || ( CodePoint <= 0xffff
+ && CodePoint >= 0xe000);
+}
+
+
+/**
+ * Folds a unicode code point to lower case.
+ *
+ * @returns Folded code point.
+ * @param CodePoint The unicode code point to fold.
+ */
+DECLINLINE(size_t) RTUniCpCalcUtf8Len(RTUNICP CodePoint)
+{
+ if (CodePoint < 0x80)
+ return 1;
+ return 2
+ + (CodePoint >= 0x00000800)
+ + (CodePoint >= 0x00010000)
+ + (CodePoint >= 0x00200000)
+ + (CodePoint >= 0x04000000)
+ + (CodePoint >= 0x80000000) /* illegal */;
+}
+
+
+
RT_C_DECLS_END
/** @} */