Show how to use format xtd::format class with characters.
#include <xtd/console>
#include <xtd/environment>
#include <xtd/string>
#include <xtd/u32string>
enum class cap {title, middle, end};
if (c == cap::title)
console::out << "┌───────────┬────────────┬──────────────────────────────────┐" << environment::new_line
<< "│ char │ format │ representation │" << environment::new_line
<< "├───────────┼────────────┼──────────────────────────────────┤" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {} │ " << u32string::format("{}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:g} │ " << u32string::format("{:g}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:G} │ " << u32string::format("{:G}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:d} │ " << u32string::format("{:d}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:D} │ " << u32string::format("{:D}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:x} │ " << u32string::format("{:x}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:X} │ " << u32string::format("{:X}", value).pad_right(32) << " |" << environment::new_line;
console::out << "│ " << text.pad_right(9) << " │ {:ANY_FMT} │ " << u32string::format("{:ANY_FMT}", value).pad_right(32) << " |" << environment::new_line;
if (c != cap::end)
console::out << "├───────────┼────────────┼──────────────────────────────────┤" << environment::new_line;
else
console::out << "└───────────┴────────────┴──────────────────────────────────┘" << environment::new_line;
}
auto main() -> int {
console::output_code_page(65001);
print_character(string {"a"}, 'a', cap::title);
print_character(string {u8"1"}, u8'1', cap::middle);
print_character(string {L"\x1F603"}, L'\x1F603', cap::middle);
print_character(
string {
u"\u4eb0"},
u'\u4eb0', cap::middle);
print_character(string {U"\U0001F428"}, U'\U0001F428', cap::end);
}
Represents text as a sequence of character units.
Definition basic_string.h:79
char32_t char32
Represents a 32-bit unicode character.
Definition char32.h:26
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10