[uClibc 0000686]: utf-8 mbrtowc incorrectly returns -2 in some cases

bugs at busybox.net bugs at busybox.net
Mon Feb 6 08:40:14 UTC 2006


The following issue has been SUBMITTED. 
====================================================================== 
http://busybox.net/bugs/view.php?id=686 
====================================================================== 
Reported By:                rfelker
Assigned To:                uClibc
====================================================================== 
Project:                    uClibc
Issue ID:                   686
Category:                   Standards Compliance
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     assigned
====================================================================== 
Date Submitted:             02-06-2006 00:40 PST
Last Modified:              02-06-2006 00:40 PST
====================================================================== 
Summary:                    utf-8 mbrtowc incorrectly returns -2 in some cases
Description: 
According to ISO C and POSIX, (size_t)-2 is returned:

If the next n bytes contribute to an incomplete but potentially valid
character, and all n bytes have been processed (no value is stored).

uClibc's mbrtowc will return -2 when given input such as [0xc0] (1 byte)
or [0xed 0xa0] (2 bytes), even though these are NOT potentially valid,
i.e. not initial subsequences of a valid UTF-8 sequence. This behavior
complicates a calling program's logic for detecting where an encoding
error occurred when attempting to resync, and probably causes scanf to
behave in a noncompliant way when using the %ls, %lc, or %l[ specifiers
(consuming more bytes than it should).
====================================================================== 

Issue History 
Date Modified   Username       Field                    Change               
====================================================================== 
02-06-06 00:40  rfelker        New Issue                                    
02-06-06 00:40  rfelker        Status                   new => assigned     
02-06-06 00:40  rfelker        Assigned To               => uClibc          
======================================================================




More information about the uClibc-cvs mailing list