wchar_t and wide characters

Discussion in 'C Programming' started by jjf@bcs.org.uk, Mar 13, 2006.

  1. Guest

    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.
     
    , Mar 13, 2006
    #1
    1. Advertising

  2. P.J. Plauger Guest

    <> wrote in message
    news:...

    > 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
     
    P.J. Plauger, Mar 13, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Web Developer

    char 8bit wide or 7bit wide in c++?

    Web Developer, Jul 31, 2003, in forum: C++
    Replies:
    2
    Views:
    591
    John Harrison
    Jul 31, 2003
  2. Replies:
    4
    Views:
    3,293
  3. Replies:
    3
    Views:
    1,114
    James Kanze
    Aug 15, 2008
  4. Disc Magnet
    Replies:
    2
    Views:
    723
    Jukka K. Korpela
    May 15, 2010
  5. Disc Magnet
    Replies:
    2
    Views:
    793
    Neredbojias
    May 14, 2010
Loading...

Share This Page