wchar_t and wide characters

J

jjf

Do Standard C's wide characters and wide strings require absolutely
that each character be stored in a single wchar_t, or can characters be
"multi-wchar_t" in the same way that they can be multibyte? Is it a
requirement that the number of wchar_t's in a string is the same as the
number of characters in the string (give or take the terminal null
character)?

The particular case I'm puzzling over is whether or not it is
conforming for an implementation with a 16-bit wchar_t to use UTF-16 as
a character encoding, since this would require some characters to be
endoded as two wchar_t's. I understand that this is what one popular
C-like implementation does.
 
P

P.J. Plauger

Do Standard C's wide characters and wide strings require absolutely
that each character be stored in a single wchar_t, or can characters be
"multi-wchar_t" in the same way that they can be multibyte? Is it a
requirement that the number of wchar_t's in a string is the same as the
number of characters in the string (give or take the terminal null
character)?

The particular case I'm puzzling over is whether or not it is
conforming for an implementation with a 16-bit wchar_t to use UTF-16 as
a character encoding, since this would require some characters to be
endoded as two wchar_t's. I understand that this is what one popular
C-like implementation does.

The *intent* is that an array of wchar_t use one element to store
each character. Certainly all the added wide-character functions
implicitly assume so. There's nothing stopping an implementation
from using UTF-16 as a wide-character encoding, however, and not
living up to this intent. Indeed, as you observe, UTF-16 is now
used in implementations that thought UCS-2 would be sufficient a
decade ago. Some of us have bowed to the inevitable and now supply
the necessary conversion software to support what you call
multi-wchar_t encodings.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top