What is the easiest way to determine if a character is in Unicode range, in Rust?
rust, unicode-string
Solution
The simplest way for me to match a character was this
fn match_char(data: &char) -> bool {
match *data {
'\x01'...'\x08' |
'\u{10FFFE}'...'\u{10FFFF}' => true,
_ => false,
}
}
Pattern matching a character was the easiest route for me, compared to a bunch of `if` statements. It might not be the most performant solution, but it served me very well.
Problem
I'm looking for easiest way to determine if a character in Rust is between two Unicode values. For example, I want to know if a character `s` is between `[#x1-#x8]` or `[#x10FFFE-#x10FFFF]`. Is there a function that does this already?