🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

4 total messages Started by Jamshid Afshar Mon, 04 Mar 1996 08:26
Multibyte and wide-character support
#4857
Author: Jamshid Afshar
Date: Mon, 04 Mar 1996 08:26
21 lines
1234 bytes
Is there an easy way to test if a multibyte string contains only
singlebyte characters and thus can be passed to a function expecting a
"regular" char*?  Is "if (strlen(mbs)==mblen(mbs))" a valid test and
is there anything better?

Why aren't there wchar_t versions of functions like atoi() strtod()?
Do they just have to be converted to multibyte strings, and do atoi(),
etc. work with multibyte strings?

Btw, VC++4's docs say that if mbstowcs()'s wchar_t* destination
argument is NULL then the function doesn't do a conversion of the
multibyte string; it just returns the size needed to store the
multibyte string.  Accepting a NULL first argument is not required by
Standard C, is it?  Also, the VC++4 docs seem to indicate fputws(), a
wchar_t version of fputs(), is "ANSI" compatible.  Standard C doesn't
actually specify any wide-character i/o functions, does it?

Thanks,
Jamshid Afshar
jamshid@io.com
Re: Multibyte and wide-character support
#4877
Author: J. Kanze
Date: Thu, 07 Mar 1996 12:58
58 lines
2929 bytes
In article <4he9gg$m9l@pentagon.io.com> jamshid@io.com (Jamshid Afshar)
writes:

|> Is there an easy way to test if a multibyte string contains only
|> singlebyte characters and thus can be passed to a function expecting a
|> "regular" char*?  Is "if (strlen(mbs)==mblen(mbs))" a valid test and
|> is there anything better?

"if ( strlen( mbs ) == mblen( mbs ) )" is definitly wrong.  mblen
returns the number of byte in a (single) multi-byte character, not in
the string.  About the only way I can think of doing this is by brute
force, with a loop:

	bool				isMultibyte = false ;
	while ( ! isMultibyte && *mbs != '\0' )
	{
		int					n = mblen( mbs , -1 ) ;
		isMultibyte = (n > 1) ;
		mbs += n ;
	}

|> Why aren't there wchar_t versions of functions like atoi() strtod()?
|> Do they just have to be converted to multibyte strings, and do atoi(),
|> etc. work with multibyte strings?

According to the standard: ``In other that the "C" locale, additional
implementation-defined subject sequence forms may be accepted.''  In
plain English: the implementor is allowed to support them, but not
required to.

|> Btw, VC++4's docs say that if mbstowcs()'s wchar_t* destination
|> argument is NULL then the function doesn't do a conversion of the
|> multibyte string; it just returns the size needed to store the
|> multibyte string.  Accepting a NULL first argument is not required by
|> Standard C, is it?

No mention of it in my copy of the standard.

|> Also, the VC++4 docs seem to indicate fputws(), a
|> wchar_t version of fputs(), is "ANSI" compatible.  Standard C doesn't
|> actually specify any wide-character i/o functions, does it?

There not in the index, anyway.

The actual support for internationalization in C is very weak.  The only
justification for this is that when the C standard was adopted, such
support was totally lacking in all other languages; C was a definite
inovater in this respect.

I believe that there are a number of additional functions which have
been proposed for C9x.  Maybe one of the other readers can fill us in.
You might also want to check out http://www.dmk.com/dmk/index.html,
which is where all of the proposals are archived.
-- 
James Kanze           (+33) 88 14 49 00          email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs Bourgeois, 67000 Strasbourg, France
Conseils, études et réalisations en logiciel orienté objet --
              -- A la recherche d'une activité dans une region francophone
Re: Multibyte and wide-character support
#4880
Author: Larry Jones
Date: Mon, 11 Mar 1996 15:50
18 lines
1401 bytes
In article <4he9gg$m9l@pentagon.io.com>, jamshid@io.com (Jamshid Afshar) writes:
> Why aren't there wchar_t versions of functions like atoi() strtod()?

There are!  X3J11 was breaking ground in this area (I don't know of any
other language standard that addressed these issues before C did) and
they weren't sure that they knew enough to specify a complete library,
nor did they want to delay issuing the standard until they were sure,
so the original standard contained only the most basic multibyte and
wide character functions.  After the standard was issued, work continued
(primarily in Japan where they have a lot of experience working with
multibyte and wide characters) which resulted in Ammendment 1 to the C
Standard that adds wide character versions of most of the character,
string, and I/O functions.
----
Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
larry.jones@sdrc.com
Somebody's always running my life.  I never get to do what I want to do.
-- Calvin
Re: Multibyte and wide-character support
#4886
Author: Clive D.W. Feather
Date: Tue, 12 Mar 1996 06:12
23 lines
1462 bytes
In article <KANZE.96Mar7135846@gabi.gabi-soft.fr>,
J. Kanze <kanze@gabi-soft.fr> wrote:
>In article <4he9gg$m9l@pentagon.io.com> jamshid@io.com (Jamshid Afshar)
>writes:
>|> Btw, VC++4's docs say that if mbstowcs()'s wchar_t* destination
>|> argument is NULL then the function doesn't do a conversion of the
>|> multibyte string; it just returns the size needed to store the
>|> multibyte string.
> No mention of it in my copy of the standard.

But mbsrtowcs has the functionality you require.

>|> Also, the VC++4 docs seem to indicate fputws(), a
>|> wchar_t version of fputs(), is "ANSI" compatible.  Standard C doesn't
>|> actually specify any wide-character i/o functions, does it?
> There not in the index, anyway.

Then your copy is out of date. fputws is part of the C Standard.

-- 
Clive D.W. Feather                       | If you lie to the compiler,
cdwf@cityscape.co.uk   (work, preferred) | it will get its revenge.
clive@stdc.demon.co.uk (home)            |   - Henry Spencer
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads