Commit 21ad82f
fix: check codepoint count not byte length in deserialize_char (#107)
The guard s.len() != 1 used byte length, causing depythonize::<char>
to return Err(InvalidLengthChar) for any non-ASCII single-codepoint
character (e.g. 'ä' U+00E4 is 1 codepoint but 2 UTF-8 bytes).
Fix: use s.chars().count() != 1 which counts Unicode codepoints.
A test for the multibyte-codepoint case is added to de.rs.
Co-authored-by: lefty <geza.balogh@trayport.com>1 parent 0085a18 commit 21ad82f
1 file changed
Lines changed: 14 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
| 190 | + | |
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| |||
1017 | 1017 | | |
1018 | 1018 | | |
1019 | 1019 | | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
1020 | 1033 | | |
1021 | 1034 | | |
1022 | 1035 | | |
| |||
0 commit comments