UTF-8: Invalid multibyte sequence

Felix Natter felix.natter@smail.inf.fh-brs.de
Mon Jun 20 04:56:00 GMT 2011


Jonathan Nieder <jrnieder@gmail.com>
writes:

> Hi Felix,
>
> Felix Natter wrote:
>
>>   setlocale(LC_ALL,"en_US.UTF-8");
> [...]
>>   printf("buffer='%s' strlen(buffer)=%d, numChars=%d\n",
>>          buffer,
>>          strlen(buffer),
>>          mbstowcs(NULL, buffer, 0));
>> 
>>   return 0;
>> }
>> ----------
>> 
>> outputs:
>> ----------
>> buffer='aäaä' strlen(buffer)=6, numChars=-1
>> ----------
>
> Odd.  I tried this with Debian eglibc 2.13-7 (using %zu in place of %d
> to avoid 32-bit vs 64-bit portability problems) and received the
> output
>
> 	buf='aäaä' strlen(buf)=6, numChars=4
>
> Perhaps you don't have the en_US.UTF-8 locale installed.  You can
> check for that by running
>
> 	LC_ALL=en_US.UTF-8 perl
>
> and seeing if it complains.

This was the problem, thanks for the suggestion.

Best Regards,
-- 
Felix Natter



More information about the Libc-help mailing list