lib/string_exp/utf8: UnicodeChars can be tested for strict equivalence.
authorLucas Bajolet <r4pass@hotmail.com>
Mon, 21 Jul 2014 14:38:47 +0000 (10:38 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Tue, 29 Jul 2014 16:00:11 +0000 (12:00 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/string_experimentations/utf8.nit

index 95cd4d4..a1b5d44 100644 (file)
@@ -98,6 +98,18 @@ extern class UnicodeChar `{ UTF8Char* `}
                }
        `}
 
+       redef fun ==(o)
+       do
+               if o isa Char then
+                       if len != 1 then return false
+                       if code_point == o.ascii then return true
+               else if o isa UnicodeChar then
+                       if len != o.len then return false
+                       if code_point == o.code_point then return true
+               end
+               return false
+       end
+
        redef fun to_s import NativeString.to_s_with_length `{
                int len = utf8___UnicodeChar_len___impl(recv);
                char* r = malloc(len + 1);