Replies: 2 comments
-
Yes, for providing text for sure, UTF-8 is supported. Some functions need UTF-16 code units though. For these you may need to convert to and from UTF-8 offsets. In one of my projects, I've built a helper trait for fn byte_index_to_utf16_index(&self, index: usize) -> usize {
let mut utf16 = 0;
let mut buf = [0; 2];
for (bi, c) in self.char_indices() {
if bi == index {
return utf16;
}
utf16 += c.encode_utf16(&mut buf).len();
}
utf16
}
fn utf16_index_to_byte_index(&self, index: usize) -> usize {
let mut utf16 = 0;
let mut buf = [0; 2];
for (bi, c) in self.char_indices() {
if utf16 == index {
return bi;
}
utf16 += c.encode_utf16(&mut buf).len();
}
self.len()
} Hope that helps. |
Beta Was this translation helpful? Give feedback.
0 replies
-
hey! I finally figured out my issue and I was able to fix it, thanks anyway :-) marc2332/freya#622 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is it possible to use UTF-8 in SkParagraph? From what I have tested, it is using UTF-16, I know this is more of a skia question and not actually for rust-skia, but I thought you might know
Thanks 😄
Beta Was this translation helpful? Give feedback.
All reactions