Skip to main content

declares_other_encoding

Function declares_other_encoding 

Source
pub fn declares_other_encoding(code: &str) -> bool
Expand description

Whether Python, when it reads code as bytes (from its input, or the bytes literal given to exec, eval or compile), honours a coding declaration that decodes it to other text than the reader sees: it always reads the text as UTF-8. UTF-8 itself, and the ASCII-compatible encodings for a text that is all ASCII, read the same. Such code is not read: a caller that hands Python code its input does not take it for understood.