Thread: difference between char, uchar and uchar16

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    29

    difference between char, uchar and uchar16

    what is difference between char, uchar and uchar16?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    char is a standard type. uchar and uchar16 are not, so who knows what they are defined as (I would guess unsighed char and unsigned short respectively, but it's impossible to say for sure, as it could REALLY be just about anything).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    a newbie :p
    Join Date
    Aug 2008
    Location
    Zurich, Switzerland, Switzerland
    Posts
    91
    uchar is the unsigned version of char.
    i think they are both standard types.
    uchar 16 may be it is only a "typedef" of unsigned short.
    it could refer into a header file like "uchar.h" -- may be.
    check it out.

    http://www.cppreference.com/wiki/data_types

  4. #4
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    uchar & uchar16 are not standard types, but unless they are named extremely badly, they are typedefs for unsigned char and unsigned short (assuming short is 16 bits on that platform).
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

  5. #5
    Beginner leiming's Avatar
    Join Date
    Jan 2008
    Location
    Fujian, China
    Posts
    25
    I guess uchar16 is for storing UNICODE char.
    about the uchar, I have seen it in "sqlext.h", the SQLCHAR is unsigned char in fact. maybe it will be used to store a byte ranging from 0 to 255.

  6. #6
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by cpjust
    uchar & uchar16 are not standard types, but unless they are named extremely badly, they are typedefs for unsigned char and unsigned short (assuming short is 16 bits on that platform).
    It is also feasible that uchar16 might be a typedef for (unsigned) wchar_t.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Not if the defining library wants to be cross-platform.

    (Besides, there is no such thing as unsigned wchar_t.)
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  8. #8
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by CornedBee
    Besides, there is no such thing as unsigned wchar_t.
    hmm... yes, wchar_t is not a signed integer type.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed