Comment 11 for bug 1109327

Revision history for this message
In , Ævar Arnfjörð Bjarmason (avarab) wrote :

Here's a simpler testcase for this bug courtesy of Jonathan Nieder:

    #include <stdio.h>
    #include <locale.h>

    int main(void)
    {
        int n;

        setlocale(LC_CTYPE, "");
        n = printf("%.11s\n", "Author: \277");
        perror("printf");
        fprintf(stderr, "return value: %d\n", n);
        return 0;
    }

Under a C locale that'll do the right thing:

    $ LANG=C ./test
    Author: &#65533;
    printf: Success
    return value: 10

But not under a UTF-8 locale, since \277 isn't a valid UTF-8 sequence:

    $ LANG=en_US.utf8 ./test
    printf: Invalid or incomplete multibyte or wide character
    return value: -1