[Y-devel] ucs4 in wchar_t

Ben Farrell benfarrell at zoom.co.uk
Thu Feb 26 00:14:27 GMT 2004


On win32, wchar_t is 16 bits,  and on my Linux pc (Debian Unstable) its 
32 bits

In C you can't depend on any type that isn't explicit about its size, so 
int32_t for example is ok, but depending on 'long' being 4 bytes is not 
:o) I've seen platforms where int and long are the same size :p (why 
have a long type ?)

In C++ things are a little different, int's depend on the hardware (ie. 
x86 is 32bits), however 'short int' is always 16bits, and 'long int' is 
always 32bits according to this C++ book I have (Core C++ by Victor 
Shtern, page 107 :).

Try the following program to find out:

int main(int argc, char* argv[])
{
    printf("sizeof(wchar_t) = %d\n", sizeof(wchar_t));
    return 0;
}

So I guess this backs what you say, if you want a type thats 4 bytes, 
you must use int32_t

Regards,
Ben

Rupert Mazzucco wrote:

>Recently someone converted stuff to wchar_t, in preparation
>for the server internal representation of characters in ucs4
>format.  I'm not sure that wchar_t is guaranteed to be a 32
>bit type.  Actually I'm pretty sure there are 16 bit wchar_t's
>floating around, and I don't think the standard specifies the
>size at all, only "bigger than char" or something like that.
>
>Wouldn't it be better to typedef int32_t from stdint.h as ucs4_t
>and use that?
>
>Regards,
>Rupert
>
>
>
>
>  
>




More information about the Y-devel mailing list









2026 © www.Y-Windows.Org - All Rights Reserved