changeset 94:3b0c5c599003

Add isHighSurrogate() and isLowSurrogate().
author Jordan Miner <jminer7@gmail.com>
date Tue, 07 Jun 2011 15:41:46 -0500
parents 8b2d3b3cbca6
children 592f7aa40bf1
files dynamin/core/string.d
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/dynamin/core/string.d	Tue Jun 07 15:33:39 2011 -0500
+++ b/dynamin/core/string.d	Tue Jun 07 15:41:46 2011 -0500
@@ -69,6 +69,23 @@
 	return str;
 }
 */
+
+// TODO: move to encoding.d
+/**
+  * Returns true if the specified code unit is a high surrogate, in the range of 0xD800 to 0xDBFF.
+  * A high surrogate comes before a low surrogate in a surrogate pair.
+  */
+bool isHighSurrogate(wchar c) {
+	return c >= 0xD800 && c <= 0xDBFF;
+}
+/**
+ * Returns true if the specified code unit is a low surrogate, in the range of 0xDC00 to 0xDFFF.
+ * A low surrogate comes after a high surrogate in a surrogate pair.
+ */
+bool isLowSurrogate(wchar c) {
+	return c >= 0xDC00 && c <= 0xDFFF;
+}
+
 Layout!(char) formatter;
 static this() {
 	formatter = new Layout!(char);