stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Sebor <se...@roguewave.com>
Subject Re: STDCXX-435
Date Wed, 12 Mar 2008 22:00:41 GMT
Eric Lemings wrote:
>  
> 
>> -----Original Message-----
>> From: Martin Sebor [mailto:sebor@roguewave.com] 
>> Sent: Wednesday, March 12, 2008 10:52 AM
>> To: dev@stdcxx.apache.org
>> Subject: Re: STDCXX-435
>>
>> Eric Lemings wrote:
>> [...]
>>> Right.  And I believe that limit is
>>>
>>> 	min(__from_end-__from, __to_limit-__to)
>> Suppose MB_CUR_MAX=4, the size of the source sequence is 1 byte
>> (with no terminating NUL), and the byte doesn't form a complete
>> multibyte character. There's no way to tell the function not to
>> attempt to read past the first byte.
> 
> I could be missing something but wouldn't this constitute an invalid
> conversion?

Not invalid -- incomplete. The only way to tell whether it's valid
or not is to look at the next byte. Which is exactly what mbsrtowcs()
will do: read past the first source byte in an effort to determine
what the rest of the multibyte character is. This first byte could
be something like "\xc2" in UTF-8 which doesn't mean anything by
itself but needs one other byte to form a valid character.

Martin


Mime
View raw message