lib/string_exp/utf8: UnicodeChars can be tested for strict equivalence.
[nit.git] / 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);