(ch: CodePoint)
| 198 | } |
| 199 | |
| 200 | fn escaped_char_len(ch: CodePoint) -> usize { |
| 201 | // surrogates are \uHHHH |
| 202 | let Some(ch) = ch.to_char() else { return 6 }; |
| 203 | match ch { |
| 204 | '\\' | '\t' | '\r' | '\n' => 2, |
| 205 | ch if ch < ' ' || ch as u32 == 0x7f => 4, // \xHH |
| 206 | ch if ch.is_ascii() => 1, |
| 207 | ch if crate::char::is_printable(ch) => { |
| 208 | // max = std::cmp::max(ch, max); |
| 209 | ch.len_utf8() |
| 210 | } |
| 211 | ch if (ch as u32) < 0x100 => 4, // \xHH |
| 212 | ch if (ch as u32) < 0x10000 => 6, // \uHHHH |
| 213 | _ => 10, // \uHHHHHHHH |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | fn write_char( |
| 218 | ch: CodePoint, |
nothing calls this directly
no test coverage detected