lib/standard/bytes: Update bytes::to_s for cleaning purposes
authorLucas Bajolet <r4pass@hotmail.com>
Wed, 12 Aug 2015 18:53:01 +0000 (14:53 -0400)
committerLucas Bajolet <r4pass@hotmail.com>
Wed, 12 Aug 2015 18:53:49 +0000 (14:53 -0400)
Signed-off-by: Lucas Bajolet <r4pass@hotmail.com>

lib/standard/bytes.nit

index 0e71a90..52e3b21 100644 (file)
@@ -145,7 +145,12 @@ class Bytes
 
        redef fun to_s do
                persisted = true
-               return new FlatString.with_infos(items, length, 0, length -1)
+               var b = self
+               if not is_utf8 then
+                       b = clean_utf8
+                       persisted = false
+               end
+               return new FlatString.with_infos(b.items, b.length, 0, b.length -1)
        end
 
        redef fun iterator do return new BytesIterator.with_buffer(self)