6

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.

4

1 に答える 1

2

最もC++-yの方法は、おそらくOgonekなどのライブラリを経由するでしょう。残念ながら、関連する機能は現時点ではまだ実装されていません。

R. Martinho Fernandes(メンテナ)は、次のように表示する必要があると言っています。

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 };
        }

        …
    }
}

次に、Unicodeコードポイント(27など)の名前を次のように表示するだけです。

std::cout << ogonek::ucd::get_name(27);
于 2012-11-06T15:00:14.450 に答える