Title
what does ctype::do_widen() return on failure
Status
nad
Section
[locale.ctype.virtuals]
Submitter
Martin Sebor

Created on 2003-09-18.00:00:00 last changed 171 months ago

Messages

Date: 2010-10-21.18:28:33

[ 2009-07 Frankfurt ]

NAD. The behavior is specified for all of the facets that an implementation is required to provide, for the basic character set.

Date: 2010-10-21.18:28:33

[ Kona: This is a real problem. Widening can fail. It's unclear what the solution should be. Returning WEOF works for the wchar_t specialization, but not in general. One option might be to add a default, like narrow. But that's an incompatible change. Using traits::eof might seem like a good idea, but facets don't have access to traits (a recurring problem). We could have widen throw an exception, but that's a scary option; existing library components aren't written with the assumption that widen can throw. ]

Date: 2003-09-18.00:00:00

The Effects and Returns clauses of the do_widen() member function of the ctype facet fail to specify the behavior of the function on failure. That the function may not be able to simply cast the narrow character argument to the type of the result since doing so may yield the wrong value for some wchar_t encodings. Popular implementations of ctype<wchar_t> that use mbtowc() and UTF-8 as the native encoding (e.g., GNU glibc) will fail when the argument's MSB is set. There is no way for the the rest of locale and iostream to reliably detect this failure.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2552
2010-10-21 18:28:33adminsetmessages: + msg2551
2003-09-18 00:00:00admincreate