about summary refs log tree commit diff
path: root/src/libunicode
diff options
context:
space:
mode:
Diffstat (limited to 'src/libunicode')
-rw-r--r--src/libunicode/u_str.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libunicode/u_str.rs b/src/libunicode/u_str.rs
index 917c2d2dfbe..0fbc98ea73c 100644
--- a/src/libunicode/u_str.rs
+++ b/src/libunicode/u_str.rs
@@ -244,7 +244,7 @@ impl<'a> Iterator for Graphemes<'a> {
         }
 
         self.cat = if take_curr {
-            idx = self.string.char_range_at(idx).next;
+            idx = idx + len_utf8(self.string.char_at(idx));
             None
         } else {
             Some(cat)
@@ -256,6 +256,11 @@ impl<'a> Iterator for Graphemes<'a> {
     }
 }
 
+#[cfg(stage0)]
+fn len_utf8(c: char) -> usize { UCharExt::len_utf8(c) }
+#[cfg(not(stage0))]
+fn len_utf8(c: char) -> usize { c.len_utf8() }
+
 impl<'a> DoubleEndedIterator for Graphemes<'a> {
     #[inline]
     fn next_back(&mut self) -> Option<&'a str> {