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

Method parse_octet

crates/codegen/src/string_parser.rs:85–102  ·  view source on GitHub ↗
(&mut self, o: u8)

Source from the content-addressed store, hash-verified

83 }
84
85 fn parse_octet(&mut self, o: u8) -> char {
86 let mut radix_bytes = [o, 0, 0];
87 let mut len = 1;
88
89 while len < 3 {
90 let Some(b'0'..=b'7') = self.peek_byte() else {
91 break;
92 };
93
94 radix_bytes[len] = self.next_byte().unwrap();
95 len += 1;
96 }
97
98 // OK because radix_bytes is always going to be in the ASCII range.
99 let radix_str = core::str::from_utf8(&radix_bytes[..len]).expect("ASCII bytes");
100 let value = u32::from_str_radix(radix_str, 8).unwrap();
101 char::from_u32(value).unwrap()
102 }
103
104 fn parse_unicode_name(&mut self) -> Result<char, LexicalError> {
105 let Some('{') = self.next_char() else {

Callers 1

parse_escaped_charMethod · 0.80

Calls 3

next_byteMethod · 0.80
peek_byteMethod · 0.45
unwrapMethod · 0.45

Tested by

no test coverage detected