MCPcopy Index your code
hub / github.com/RustPython/RustPython / next_surrogate

Method next_surrogate

crates/wtf8/src/lib.rs:930–957  ·  view source on GitHub ↗
(&self, mut pos: usize)

Source from the content-addressed store, hash-verified

928
929 #[inline]
930 fn next_surrogate(&self, mut pos: usize) -> Option<(usize, u16)> {
931 let mut iter = self.bytes[pos..].iter();
932 loop {
933 let b = *iter.next()?;
934 if b < 0x80 {
935 pos += 1;
936 } else if b < 0xE0 {
937 iter.next();
938 pos += 2;
939 } else if b == 0xED {
940 match (iter.next(), iter.next()) {
941 (Some(&b2), Some(&b3)) if b2 >= 0xA0 => {
942 return Some((pos, decode_surrogate(b2, b3)));
943 }
944 _ => pos += 3,
945 }
946 } else if b < 0xF0 {
947 iter.next();
948 iter.next();
949 pos += 3;
950 } else {
951 iter.next();
952 iter.next();
953 iter.next();
954 pos += 4;
955 }
956 }
957 }
958
959 pub fn is_code_point_boundary(&self, index: usize) -> bool {
960 is_code_point_boundary(self, index)

Callers 5

into_string_lossyMethod · 0.80
fmtMethod · 0.80
to_string_lossyMethod · 0.80
is_utf8Method · 0.80
nextMethod · 0.80

Calls 4

decode_surrogateFunction · 0.85
SomeClass · 0.50
iterMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected