src: Compiler, interpreter and parser updates for UTF-8
[nit.git] / src / interpreter / naive_interpreter.nit
index 78bd4e2..61889c7 100644 (file)
@@ -275,10 +275,10 @@ class NaiveInterpreter
        # Return a new native string initialized with `txt`
        fun native_string_instance(txt: String): Instance
        do
-               var instance = native_string_instance_len(txt.length+1)
+               var instance = native_string_instance_len(txt.bytelen+1)
                var val = instance.val
-               val[txt.length] = 0u8
-               txt.to_cstring.copy_to(val, txt.length, 0, 0)
+               val[txt.bytelen] = 0u8
+               txt.to_cstring.copy_to(val, txt.bytelen, 0, 0)
 
                return instance
        end
@@ -298,7 +298,7 @@ class NaiveInterpreter
        fun string_instance(txt: String): Instance
        do
                var nat = native_string_instance(txt)
-               var res = self.send(self.force_get_primitive_method("to_s_with_length", nat.mtype), [nat, self.int_instance(txt.length)])
+               var res = self.send(self.force_get_primitive_method("to_s_with_length", nat.mtype), [nat, self.int_instance(txt.bytelen)])
                assert res != null
                return res
        end