nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
bbf753a
)
lib/core: Added surrogate detection methods to `Char`
author
Lucas Bajolet
<r4pass@hotmail.com>
Fri, 6 May 2016 15:42:39 +0000
(11:42 -0400)
committer
Lucas Bajolet
<r4pass@hotmail.com>
Fri, 6 May 2016 15:42:39 +0000
(11:42 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>
lib/core/text/abstract_text.nit
patch
|
blob
|
history
diff --git
a/lib/core/text/abstract_text.nit
b/lib/core/text/abstract_text.nit
index
c15901e
..
6c2acd4
100644
(file)
--- a/
lib/core/text/abstract_text.nit
+++ b/
lib/core/text/abstract_text.nit
@@
-1755,6
+1755,18
@@
redef class Char
return cp >= 0xD800 and cp <= 0xDFFF
end
+ # Is `self` a UTF-16 high surrogate ?
+ fun is_hi_surrogate: Bool do
+ var cp = code_point
+ return cp >= 0xD800 and cp <= 0xDBFF
+ end
+
+ # Is `self` a UTF-16 low surrogate ?
+ fun is_lo_surrogate: Bool do
+ var cp = code_point
+ return cp >= 0xDC00 and cp <= 0xDFFF
+ end
+
# Length of `self` in a UTF-8 String
fun u8char_len: Int do
var c = self.code_point