Pure Programmer
Blue Matrix


Cluster Map

Project: Character Types

We can group characters in the Unicode character set by attributes that the characters have. Is it a letter? Is it a whitespace character? Is it a control character? Write a program that defines a string of interesting characters. Then iterate on that string, character by character, printing out the character and its attributes using the character typing functions.

Output
$ rustc CharacterTypes.rs error[E0425]: cannot find value `Utils` in this scope --> CharacterTypes.rs:14:32 | 14 | print!("Processing: 0x{} ", Utils.toBase(u32(c), 16)); | ^^^^^ not found in this scope error[E0425]: cannot find function `isctrl` in this scope --> CharacterTypes.rs:13:6 | 13 | if isctrl(c) || isspace(c) { | ^^^^^^ not found in this scope error[E0425]: cannot find function `isspace` in this scope --> CharacterTypes.rs:13:19 | 13 | if isctrl(c) || isspace(c) { | ^^^^^^^ not found in this scope error[E0423]: expected function, found builtin type `u32` --> CharacterTypes.rs:14:45 | 14 | print!("Processing: 0x{} ", Utils.toBase(u32(c), 16)); | ^^^ not a function error[E0425]: cannot find function `isalpha` in this scope --> CharacterTypes.rs:18:6 | 18 | if isalpha(c) { | ^^^^^^^ not found in this scope error[E0425]: cannot find function `toupper` in this scope --> CharacterTypes.rs:19:27 | 19 | print!("isalpha {}{}", toupper(c), tolower(c)); | ^^^^^^^ not found in this scope error[E0425]: cannot find function `tolower` in this scope --> CharacterTypes.rs:19:39 | 19 | print!("isalpha {}{}", toupper(c), tolower(c)); | ^^^^^^^ not found in this scope error[E0425]: cannot find function `isalnum` in this scope --> CharacterTypes.rs:22:6 | 22 | if isalnum(c) { | ^^^^^^^ not found in this scope error[E0425]: cannot find function `isdigit` in this scope --> CharacterTypes.rs:29:6 | 29 | if isdigit(c) { | ^^^^^^^ not found in this scope error[E0425]: cannot find function `isspace` in this scope --> CharacterTypes.rs:36:6 | 36 | if isspace(c) { | ^^^^^^^ not found in this scope error[E0425]: cannot find function `ispunct` in this scope --> CharacterTypes.rs:43:6 | 43 | if ispunct(c) { | ^^^^^^^ not found in this scope error[E0425]: cannot find function `isctrl` in this scope --> CharacterTypes.rs:50:6 | 50 | if isctrl(c) { | ^^^^^^ not found in this scope error: aborting due to 12 previous errors Some errors have detailed explanations: E0423, E0425. For more information about an error, try `rustc --explain E0423`.

Solution