Use byte indices instead of char indices for text runs

Replace character indices with UTF-8 byte offsets throughout the code dealing
with text shaping and breaking.  This eliminates a lot of complexity when
converting from one to the other, and interoperates better with the rest of
the Rust ecosystem.
This commit is contained in:
Matt Brubeck 2016-04-27 11:22:02 -07:00
parent dba878dfb2
commit 659305fe0a
15 changed files with 259 additions and 437 deletions

View file

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use util::str::{search_index, split_html_space_chars, str_join};
use util::str::{split_html_space_chars, str_join};
#[test]
pub fn split_html_space_chars_whitespace() {
@ -33,15 +33,3 @@ pub fn test_str_join_many() {
let expected = "-alpha--beta-gamma-";
assert_eq!(actual, expected);
}
#[test]
pub fn test_search_index() {
let tuples = [("", 1, 0),
("foo", 8, 3),
("føo", 8, 3),
("foo", 2, 2),
("føo", 2, 3)];
for t in tuples.iter() {
assert_eq!(search_index(t.1, t.0.char_indices()), t.2);
};
}