Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Question about mb_metastrlen



Hello,
the function counts bytes in last incomplete wide character:

        ret = mbrtowc(&wc, &inchar, 1, &mb_shiftstate);
        if (ret == MB_INCOMPLETE) {
            num_in_char++;
        } else {

When returning, it makes use of the count:

    /* If incomplete, treat remainder as trailing single bytes */
    return num + num_in_char;

Strings are stored in wchar_t arrays. The incomplete character will
occupy single index, correct? So maybe the return should be:

    return num + ( num_in_char > 0 ? 1 : 0 );

?

Best regards,
Sebastian Gniazdowski



Messages sorted by: Reverse Date, Date, Thread, Author