K
kyuupi
Limiting ourselves to C90 pre-amendment 1 interfaces, is there a
guaranteed way to recover from an invalid character conversion
attempt? I'm unable to find anything. In other words, suppose we
have two strings, one starts with a bad character for the current
locale, and the other doesn't, what needs to be done below for the
assertion to pass?
char bad[] = "<something>";
char ok[] = "<something else>";
void foo (void)
{
wchar_t wc;
if (mbtowc (&wc, bad, sizeof bad) == -1)
{
** what can be done here? **
assert (mbtowc (&wc, ok, sizeof ok) >= 0);
}
}
If there is nothing standardized, doesn't that render mbtowc and
friends somewhat useless in practice?
guaranteed way to recover from an invalid character conversion
attempt? I'm unable to find anything. In other words, suppose we
have two strings, one starts with a bad character for the current
locale, and the other doesn't, what needs to be done below for the
assertion to pass?
char bad[] = "<something>";
char ok[] = "<something else>";
void foo (void)
{
wchar_t wc;
if (mbtowc (&wc, bad, sizeof bad) == -1)
{
** what can be done here? **
assert (mbtowc (&wc, ok, sizeof ok) >= 0);
}
}
If there is nothing standardized, doesn't that render mbtowc and
friends somewhat useless in practice?