C++Guns – RoboBlog

24.08.2020

C++ Guns: C++20 und UTF8 Unicode

Filed under: Allgemein — Tags: — Thomas @ 11:08

In C++20 ändert sich der Typ von u8 string literals von char nach char8_t. Damit compiliert älterer Code nicht mehr

GCC10 Error so far:

error: use of deleted function 'std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char8_t*) [with _Traits = std::char_traits<char>]'

Ich sag es mal positiv: ein weitere Schritt ist gemacht. Und bis dahin behelfen wir uns mit dreckigen casts:

auto func(std::ostream& ss) {
    ss << reinterpret_cast<const char*>(u8"\u00e4 \u00f6 \u00fc \u2581") << "\n";
}

Ausgabe:

ä ö ü ▁

Die Verwendung von char8_t u8string und u8stringliterals ist gefühlt noch nicht ausgereift :/

No Comments

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress