rustpython_literal/char.rs
1use unic_ucd_category::GeneralCategory;
2
3/// According to python following categories aren't printable:
4/// * Cc (Other, Control)
5/// * Cf (Other, Format)
6/// * Cs (Other, Surrogate)
7/// * Co (Other, Private Use)
8/// * Cn (Other, Not Assigned)
9/// * Zl Separator, Line ('\u2028', LINE SEPARATOR)
10/// * Zp Separator, Paragraph ('\u2029', PARAGRAPH SEPARATOR)
11/// * Zs (Separator, Space) other than ASCII space('\x20').
12pub fn is_printable(c: char) -> bool {
13 let cat = GeneralCategory::of(c);
14 !(cat.is_other() || cat.is_separator())
15}