Is there a standard function for user-friendly representation of non-alphanum input characters?
Say char(27) would be "ESC" or "Escape" or something alike.
I am asking this because that would be an easy way for me to display help on controls in command line.
EDIT:
As @ypnos pointed out: the question is how to avoid defining my own key names.
I wonder if there was a function in boost or std or some basic lib which I missed?
For now, Ascii-only could work for me but I am looking for a "standard" solution because I don't want to reimplement once dealing with Unicode input -- say characters with accents not in Ascii -- later on.
My program code will be sent over to Linux and Windows and I also don't want that the names would be faulty at places.
The most C++-y way would probably via a library such as Ogonek. Unfortunately, the relevant function isn’t yet implemented at the moment.
R. Martinho Fernandes (the maintainer) tells me that it should look as follows:
namespace ogonek {
namespace ucd {
…
basic_text<utf8> get_name(codepoint u) {
return basic_text<utf8> {
find_property_group(name_data, name_data_size, u).name };
}
…
}
}
And then you could simply display a Unicode code point’s (27, say) name using
std::cout << ogonek::ucd::get_name(27);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With