More correct wrap_rows implementation
parent
dd91b3d6fb
commit
d7190df07e
|
@ -426,18 +426,12 @@ inline std::string wrap_rows(const std::string &from,
|
||||||
{
|
{
|
||||||
std::string to;
|
std::string to;
|
||||||
|
|
||||||
bool need_to_wrap = false;
|
|
||||||
|
|
||||||
size_t character_idx = 0;
|
size_t character_idx = 0;
|
||||||
for (size_t i = 0; i < from.size(); i++) {
|
for (size_t i = 0; i < from.size(); i++) {
|
||||||
if (character_idx > 0 && character_idx % row_len == 0)
|
|
||||||
need_to_wrap = true;
|
|
||||||
if (!IS_UTF8_MULTB_INNER(from[i])) {
|
if (!IS_UTF8_MULTB_INNER(from[i])) {
|
||||||
// Wrap string if needed before next char started
|
// Wrap string after last inner byte of char
|
||||||
if (need_to_wrap) {
|
if (character_idx > 0 && character_idx % row_len == 0)
|
||||||
to += '\n';
|
to += '\n';
|
||||||
need_to_wrap = false;
|
|
||||||
}
|
|
||||||
character_idx++;
|
character_idx++;
|
||||||
}
|
}
|
||||||
to += from[i];
|
to += from[i];
|
||||||
|
|
Loading…
Reference in New Issue