Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

benburkhart1
Copy link

This resolves the issue in:

#46

@nabeards
Copy link

nabeards commented Nov 1, 2018

This also appears to resolve my issues in #50 !

@boxerab
Copy link

boxerab commented Mar 26, 2019

LGTM !!

@micolous
Copy link

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