Locale codecvt facet doesn't seem to return 'partial'

Jeffery Cavallaro jcavalla@postini.com
Thu Apr 19 17:14:00 GMT 2007


Greetings, i18n fans!

I am using the GCC 4.1.1 release on FC6, and ran across something that I
do not think is right.  I have a test that attempts to codecvt a UTF-8
string that ends with an incomplete character encoding:

typedef std::string::traits_type::state_type State;

typedef std::codecvt<
    std::wstring::value_type, std::string::value_type, State
> Converter;

typedef std::codecvt_base::result Result;

const string::size_type NarrowsPerWide = (
    sizeof(std::wstring::value_type) / sizeof(std::string::value_type)
);

std::string from("\xC2\xA1Hasta ma\xC3\xB1\x61na!");
wchar_t to[256];
State q;
const std::string::value_type *me = 0;
std::wstring::value_type *we = 0;

std::memset(&q, 0, sizeof(q));

Result status =
    cvt.in(
        q,
        from.data(), from.data() + from.size(), me,
        to, to + sizeof(to)/sizeof(to[0]), we
    );

This works fine, resulting in the the widened form with the upside down
'!' and the en-yay; however, if I cut
the source string off at the first byte of the encoded en-yay:

std::string from("\xC2\xA1Hasta ma\xC3");

the codecvt facet in method still returns 'ok' and simply ignores the
incomplete UTF-8 sequence.  Shouldn't
it have returned 'partial'?

Thanks to all in advance.

-- 
Jeffery Cavallaro
POSTINI
Engineering Group
650-486-8342







-----------------------------------------------------------
This message may contain confidential and/or privileged 
information. This information is intended to be read only
by the individual or entity to whom it is addressed. If
you are not the intended recipient, you are on notice that
any review, disclosure, copying, distribution or use of
the contents of this message is strictly prohibited. If
you have received this message in error, please notify the
sender immediately and delete or destroy any copy of this
message.



More information about the Libstdc++ mailing list