We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f113342 commit ad357d0Copy full SHA for ad357d0
vm/src/obj/objbyteinner.rs
@@ -74,6 +74,25 @@ pub struct ByteInnerNewOptions {
74
encoding: OptionalArg<PyStringRef>,
75
}
76
77
+//same algorithm as cpython
78
+pub fn normalize_encoding(encoding: &str) -> String {
79
+ let mut res = String::new();
80
+ let mut punct = false;
81
+
82
+ for c in encoding.chars() {
83
+ if c.is_alphanumeric() || c == '.' {
84
+ if punct && !res.is_empty() {
85
+ res.push('_')
86
+ }
87
+ res.push(c.to_ascii_lowercase());
88
+ punct = false;
89
+ } else {
90
+ punct = true;
91
92
93
+ res
94
+}
95
96
impl ByteInnerNewOptions {
97
pub fn get_value(self, vm: &VirtualMachine) -> PyResult<PyByteInner> {
98
// First handle bytes(string, encoding[, errors])
0 commit comments