Small class that makes console input/output with utf-8 easier in c++17.
auto const input = unicode_console::read<std::string>();
Or:
std::string input;
unicode_console::io >> input
auto const input = unicode_console::readln();
unicode_console::println("Here is a little unicode: åäö ÿëã")
.println("And a number: ", 1234);
Or:
unicode_console::io << "Here is a little unicode: åäö ÿëã\n"
<< "And a number: " << 1234 << '\n';
auto const input = unicode_console::read_validated<double>("That's not a number! Try again.");
// input should be between -3.14 and 3.14
auto const input = unicode_console::read_validated<double>(
[](auto const input) {
return input > -3.14 && input < 3.14;
},
"Invalid input! Try again."
);
// input should be between -3.14 and 3.14
auto const input = unicode_console::read_validated<double>(
[](auto const input) {
return input > -3.14 && input < 3.14;
},
"That's outside of the range! Try again.",
"That's not a number!"
);