From: Lucas Bajolet Date: Wed, 12 Aug 2015 18:53:01 +0000 (-0400) Subject: lib/standard/bytes: Update bytes::to_s for cleaning purposes X-Git-Tag: v0.7.8~80^2~5 X-Git-Url: http://nitlanguage.org lib/standard/bytes: Update bytes::to_s for cleaning purposes Signed-off-by: Lucas Bajolet --- diff --git a/lib/standard/bytes.nit b/lib/standard/bytes.nit index 0e71a90..52e3b21 100644 --- a/lib/standard/bytes.nit +++ b/lib/standard/bytes.nit @@ -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)