(bytes: &[u8])
| 288 | } |
| 289 | |
| 290 | fn escape_unicode(bytes: &[u8]) -> String { |
| 291 | let show = match ::std::str::from_utf8(bytes) { |
| 292 | Ok(v) => v.to_string(), |
| 293 | Err(_) => escape_bytes(bytes), |
| 294 | }; |
| 295 | let mut space_escaped = String::new(); |
| 296 | for c in show.chars() { |
| 297 | if c.is_whitespace() { |
| 298 | let escaped = if c as u32 <= 0x7F { |
| 299 | escape_byte(c as u8) |
| 300 | } else { |
| 301 | if c as u32 <= 0xFFFF { |
| 302 | format!(r"\u{{{:04x}}}", c as u32) |
| 303 | } else { |
| 304 | format!(r"\U{{{:08x}}}", c as u32) |
| 305 | } |
| 306 | }; |
| 307 | space_escaped.push_str(&escaped); |
| 308 | } else { |
| 309 | space_escaped.push(c); |
| 310 | } |
| 311 | } |
| 312 | space_escaped |
| 313 | } |
| 314 | |
| 315 | fn escape_bytes(bytes: &[u8]) -> String { |
| 316 | let mut s = String::new(); |
nothing calls this directly
no test coverage detected