lib/string_exp/utf8: Fixed print routine to support UTF8 strings.
authorLucas Bajolet <r4pass@hotmail.com>
Tue, 29 Jul 2014 15:13:42 +0000 (11:13 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Tue, 29 Jul 2014 16:01:03 +0000 (12:01 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/string_experimentations/utf8.nit

index b1ba7d1..7261820 100644 (file)
@@ -16,6 +16,7 @@
 module utf8
 
 intrude import standard::string
+intrude import standard::file
 
 in "C Header" `{
 
@@ -396,3 +397,17 @@ redef class NativeString
                return new FlatString.with_infos_index(new_self, real_len.item, 0, real_len.item - 1, x, length)
        end
 end
+
+redef class OFStream
+       redef fun write(s)
+       do
+               assert _writable
+               if s isa FlatText then
+                       if s isa FlatString then
+                               write_native(s.to_cstring, s.bytelen)
+                       else
+                               write_native(s.to_cstring, s.length)
+                       end
+               else for i in s.substrings do write_native(i.to_cstring, i.length)
+       end
+end