tabulate
tabulate copied to clipboard
After setting the width of the table, Chinese characters may appear with incorrect line breaks.
Talk is cheap, Let me show you my code.
#include <iostream>
#include <tabulate/table.hpp>
using namespace tabulate;
int main() {
Table table;
table.add_row({"ID", "Status", "Score"});
table.add_row({"1", "✔ Passed", "85"});
table.add_row({"2", "✘ Failed", "40"});
table.add_row({"3", "✔ Passed", "95"});
table.add_row({"4", "这是一条非常长的中文注释,可以解析吗?", "95"});
table.add_row({"5", "Is there any problem with this very long English comment?", "95"});
table.column(1).format().multi_byte_characters(true);
table.column(1).format().width(20);
table[1][1].format().font_color(Color::green);
table[2][1].format().font_color(Color::red);
table[3][1].format().font_color(Color::green);
std::cout << table << std::endl;
return 0;
}