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

Function utf_8_encode

crates/vm/src/stdlib/_codecs.rs:200–210  ·  view source on GitHub ↗
(args: EncodeArgs, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

198
199 #[pyfunction]
200 fn utf_8_encode(args: EncodeArgs, vm: &VirtualMachine) -> EncodeResult {
201 if args.s.is_utf8()
202 || args
203 .errors
204 .as_ref()
205 .is_some_and(|s| s.is(identifier!(vm, surrogatepass)))
206 {
207 return Ok((args.s.as_bytes().to_vec(), args.s.byte_len()));
208 }
209 do_codec!(utf8::encode, args, vm)
210 }
211
212 #[pyfunction]
213 fn utf_8_decode(args: DecodeArgs, vm: &VirtualMachine) -> DecodeResult {

Callers

nothing calls this directly

Calls 6

isMethod · 0.80
to_vecMethod · 0.80
is_utf8Method · 0.45
as_refMethod · 0.45
as_bytesMethod · 0.45
byte_lenMethod · 0.45

Tested by

no test coverage detected