nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib/core: remove uses of Byte for Text
[nit.git]
/
lib
/
core
/
codecs
/
utf8.nit
diff --git
a/lib/core/codecs/utf8.nit
b/lib/core/codecs/utf8.nit
index
debb3f5
..
c37bd35
100644
(file)
--- a/
lib/core/codecs/utf8.nit
+++ b/
lib/core/codecs/utf8.nit
@@
-54,7
+54,7
@@
private class UTF8Codec
redef fun is_valid_char(ns, len) do
if len == 0 then return 2
if not ns[0].is_valid_utf8_start then return 2
redef fun is_valid_char(ns, len) do
if len == 0 then return 2
if not ns[0].is_valid_utf8_start then return 2
- for i in [1 .. len[ do if ns[i] & 0b1100_0000u8 != 0b1000_0000u8 then return 2
+ for i in [1 .. len[ do if ns[i] & 0b1100_0000 != 0b1000_0000 then return 2
if len != ns[0].u8len then return 1
return 0
end
if len != ns[0].u8len then return 1
return 0
end
@@
-68,12
+68,13
@@
private class UTF8Codec
end
redef fun decode_string(ns, len) do
end
redef fun decode_string(ns, len) do
- var ret = ns.to_s_with_length(len)
+ assert len >= 0
+ var ret = ns.to_s_unsafe(len, copy=false)
var rit = ret.as(FlatString).items
if rit == ns then
var nns = new CString(len)
rit.copy_to(nns, len, 0, 0)
var rit = ret.as(FlatString).items
if rit == ns then
var nns = new CString(len)
rit.copy_to(nns, len, 0, 0)
- return nns.to_s_full(ret.byte_length, ret.length)
+ return nns.to_s_unsafe(ret.byte_length, ret.length, copy=false)
end
return ret
end
end
return ret
end