Fix byte_len in char_len_range to be what it is advertised.
This commit is contained in:
parent
33f4a98388
commit
e127bf680f
1 changed files with 3 additions and 3 deletions
|
@ -1067,14 +1067,14 @@ FIXME: rename to 'substr_len_chars'
|
|||
*/
|
||||
fn char_len_range(s: str, byte_start: uint, byte_len: uint) -> uint {
|
||||
let i = byte_start;
|
||||
let byte_stop = i + byte_len;
|
||||
let len = 0u;
|
||||
while i < byte_len {
|
||||
while i < byte_stop {
|
||||
let chsize = utf8_char_width(s[i]);
|
||||
assert (chsize > 0u);
|
||||
len += 1u;
|
||||
i += chsize;
|
||||
}
|
||||
assert (i == byte_len);
|
||||
ret len;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue