473,387 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

mbtowc recovery

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?

Sep 6 '07 #1
1 1420
kyuupi wrote:
Limiting ourselves to C90 pre-amendment 1 interfaces,
TTBMK, mbtowc was only added to C with amendment 1 (in 1994).
So, limiting ourselves to interfaces that predate the amendment renders
the question moot.
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?
According to the C99 standard (I don't have any other trustworthy
sources that mention the function), you can reset the conversion state
maintained by the mbtowc function with the call
mbtowc(NULL, NULL, 0)
The return value of this call indicates if the (current, locale
dependent) multi-byte character coding uses shift states or not.

I could not find any information that during the standardisation of C99
anything was changed in this area.
>
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?
Bart v Ingen Schenau
--
a.c.l.l.c-c++ FAQ: http://www.comeaucomputing.com/learn/faq
c.l.c FAQ: http://www.eskimo.com/~scs/C-faq/top.html
c.l.c++ FAQ: http://www.parashift.com/c++-faq-lite/
Sep 6 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: xixi | last post by:
i have db2 udb v8.1 on windows 64 bit 2003 server, after db2 server start , i found this in the db2diag.log, is this error? 2004-05-05-15.28.30.780000 Instance:DB2 Node:000...
3
by: jignesh shah | last post by:
Hi all, Is there a way to recover a single container if its been corrupted or mark bad without restoring whole tablespace? environment: db28.1/aix5.1/tsm/rs-6000. Regards Jignesh
9
by: Ross | last post by:
Hi, I have a question regarding how the mbtowc() and wctomb() functions work. Given that some compilers (gcc, for example) allow the wide execution character set to be specified at compile time,...
2
by: Racerx | last post by:
Hi All : I use db2 8.1 fixpack 3 on AIX. I recieved the following message in the diaglog ====================================================== ADM7513W Database manager has started. ...
4
by: Old Wolf | last post by:
As far as I can see, mbtowc and mbstowcs assume that there is exactly one wide character for each multi-byte sequence. How are you meant to cope with MBS that correspond to two wide characters? ...
1
by: Neil Booth | last post by:
What is the behaviour of mbtowc following an attempt to convert an invalid character sequence? My belief is that, if the encoding is state-independent, then mbtowc should continue to work if given...
2
by: Tin | last post by:
I bought a laptop and burned 4 recovery CDs for recovery purpose. Instead of burning as disc images, I just copied and pasted these 4 CDs to my USB HDD as 4 folders called "RecoveryCD 1",...
0
by: Winder | last post by:
Computer Data Recovery Help 24/7 Data recovering tools and services is our focus. We will recover your data in a cost effective and efficient manner. We recover all operating systems and media....
2
by: =?Utf-8?B?c3BhcmtsZWJhbg==?= | last post by:
My recovery disk on vista is almost full. I have performed a back up, deleted all but the most recent recovery point, done a disk clean up and also compressed the recovery disk. It is STILL almost...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.