Unsigned and signed char types

Discussion in 'C Programming' started by Sriniv, Jun 12, 2005.

  1. Sriniv

    Sriniv Guest

    Hello all,
    Do we have unsigned and signed char types? If so, i'd like to know the
    differences between the two.
    And one more question. Is there any provision in C for using the
    Unicode character set?
    Thank you.
    -- Srinivasan.
    Sriniv, Jun 12, 2005
    #1
    1. Advertising

  2. Sriniv wrote on 12/06/05 :
    > Do we have unsigned and signed char types?


    Yes, there are 3 char= types:

    char : used for strings

    signed char
    and
    unsigned char : used for small integers (mainly in arrays).

    > If so, i'd like to know the
    > differences between the two.


    For the signed/unsigned types, the difference is the range and the
    behaviour on overflow. More details in your C-book.

    http://publications.gbdirect.co.uk/c_book/ (C90)

    > And one more question. Is there any provision in C for using the
    > Unicode character set?


    Yes, the C95 wchar_t type and related w*() functions.

    --
    Emmanuel
    The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html
    The C-library: http://www.dinkumware.com/refxc.html

    ..sig under repair
    Emmanuel Delahaye, Jun 12, 2005
    #2
    1. Advertising

  3. Sriniv

    Ben Pfaff Guest

    "Emmanuel Delahaye" <> writes:

    > Yes, there are 3 char= types:
    >
    > char : used for strings [...]


    It is certainly true that `char' is the type most often used for
    strings. However, the C standard doesn't restrict the definition
    of "string" to `char' only:

    7.1 Introduction
    7.1.1 Definitions of terms
    1 A string is a contiguous sequence of characters terminated by
    and including the first null character.

    This may or may not be useful to know outside of comp.lang.c.
    --
    Ben Pfaff
    email:
    web: http://benpfaff.org
    Ben Pfaff, Jun 12, 2005
    #3
  4. On Sun, 12 Jun 2005 20:11:39 +0200, Emmanuel Delahaye wrote:

    > Sriniv wrote on 12/06/05 :
    >> Do we have unsigned and signed char types?

    >
    > Yes, there are 3 char= types:
    >
    > char : used for strings
    >
    > signed char
    > and
    > unsigned char : used for small integers (mainly in arrays).
    >
    >> If so, i'd like to know the
    >> differences between the two.

    >
    > For the signed/unsigned types, the difference is the range and the
    > behaviour on overflow. More details in your C-book.


    As such they are like other signed and unsigned integer types.

    > http://publications.gbdirect.co.uk/c_book/ (C90)
    >
    >> And one more question. Is there any provision in C for using the
    >> Unicode character set?

    >
    > Yes, the C95 wchar_t type and related w*() functions.


    Even C89 has some wide character support. Note that as with normal
    charcters the character encoding is not specified so it need not be
    Unicode.

    Lawrence
    Lawrence Kirby, Jun 12, 2005
    #4
  5. Sriniv <> wrote:
    > Hello all,
    > Do we have unsigned and signed char types? If so, i'd like to know the
    > differences between the two.
    > And one more question. Is there any provision in C for using the
    > Unicode character set?


    FWIW, Unicode isn't simply a "character set". It's a whole set of rules and
    methodologies. C in it's C99 incarnation is about as close to supporting
    Unicode as it was when Unix was rewritten in C 30 years ago.

    Some will mention wchar_t and the new wide character functions. But wchar_t
    gives you absolutely zilch, no matter whether it's 16-bits or 32-bits or
    128-bits. The char type suffices just as well, because no matter the width
    of the type you _still_ have combining characters, so the whole notion of
    mapping a glyph (the things you see on your screen) to a "character" is long
    dead, particularly with regards to Unicode.

    So, depending on your disposition C either has no support for Unicode, or it
    supports it just fine. IOW, you can use libraries like IBM's ICU to deal w/
    Unicode. I doubt C will ever have the type of "support" for Unicode like,
    for instance, Java has. Though it's worth mentioning that arguably Java got
    it wrong. Which is why C will never have that type of support; there's no
    single way to do it, and it's quite application specific.

    - Bill
    William Ahern, Jun 13, 2005
    #5
    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. Replies:
    9
    Views:
    1,758
    Peter Nilsson
    Jul 26, 2004
  2. Steffen Fiksdal

    void*, char*, unsigned char*, signed char*

    Steffen Fiksdal, May 8, 2005, in forum: C Programming
    Replies:
    1
    Views:
    577
    Jack Klein
    May 9, 2005
  3. At_sea_with_C

    char vs. signed or unsigned char

    At_sea_with_C, Mar 14, 2007, in forum: C Programming
    Replies:
    4
    Views:
    750
    Malcolm McLean
    Mar 14, 2007
  4. Ioannis Vranos
    Replies:
    11
    Views:
    757
    Ioannis Vranos
    Mar 28, 2008
  5. Ioannis Vranos

    Padding bits and char, unsigned char, signed char

    Ioannis Vranos, Mar 28, 2008, in forum: C Programming
    Replies:
    6
    Views:
    609
    Ben Bacarisse
    Mar 29, 2008
Loading...

Share This Page