Mercurial > projects > dynamin
diff dynamin/core/string.d @ 94:3b0c5c599003
Add isHighSurrogate() and isLowSurrogate().
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Tue, 07 Jun 2011 15:41:46 -0500 |
parents | aa4efef0f0b1 |
children | 604d20cac836 |
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);