MCPcopy Create free account
hub / github.com/p-ranav/tabulate / get_sequence_length

Function get_sequence_length

include/tabulate/utf8.hpp:74–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72#endif
73
74inline size_t get_sequence_length(const std::string &text, const std::string &locale,
75 bool is_multi_byte_character_support_enabled) {
76 if (!is_multi_byte_character_support_enabled)
77 return text.length();
78
79#if defined(_WIN32) || defined(_WIN64)
80 (void)locale; // unused parameter
81 return (text.length() - std::count_if(text.begin(), text.end(),
82 [](char c) -> bool { return (c & 0xC0) == 0x80; }));
83#elif defined(__unix__) || defined(__unix) || defined(__APPLE__)
84 auto result = get_wcswidth(text, locale, text.size());
85 if (result >= 0)
86 return result;
87 else
88 return (text.length() - std::count_if(text.begin(), text.end(),
89 [](char c) -> bool { return (c & 0xC0) == 0x80; }));
90#endif
91}
92
93} // namespace tabulate

Callers 6

sizeMethod · 0.70
get_cell_widthMethod · 0.70
word_wrapMethod · 0.70
split_linesMethod · 0.70
shapeMethod · 0.70
print_row_in_cellMethod · 0.70

Calls 4

get_wcswidthFunction · 0.70
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected