# HG changeset patch # User Jordan Miner # Date 1307479306 18000 # Node ID 3b0c5c599003d0d61c31f8db1c89e53edf3ab82e # Parent 8b2d3b3cbca60ca1a0d64033ad102aa682d22f44 Add isHighSurrogate() and isLowSurrogate(). diff -r 8b2d3b3cbca6 -r 3b0c5c599003 dynamin/core/string.d --- 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);