Skip to content

Fix bug with counting utf-8 character lengths.#49

Open
benburkhart1 wants to merge 1 commit intoszatmary:developfrom
benburkhart1:develop
Open

Fix bug with counting utf-8 character lengths.#49
benburkhart1 wants to merge 1 commit intoszatmary:developfrom
benburkhart1:develop

Conversation

@benburkhart1
Copy link
Copy Markdown

This resolves the issue in:

#46

@nabeards
Copy link
Copy Markdown

nabeards commented Nov 1, 2018

This also appears to resolve my issues in #50 !

@boxerab
Copy link
Copy Markdown

boxerab commented Mar 26, 2019

LGTM !!

@micolous
Copy link
Copy Markdown

While it may fix the issue, this change duplicates _utf8_newline, and rolls back increments in the for loop.

I'd propose something much simpler:

size_t utf8_line_length(const utf8_char_t* data)
{
    size_t n, len = 0;

    while (0 != data[len]) {
        if (0 < (n = _utf8_newline(data + len))) {
            return len + n;
        }

        len += utf8_char_length(data + len);
    }

    return len;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants