Re: unsigned char* in unicode and multibyte
I am porting an application from windows xp (multibyte) ton windowsCE
(unicode) and I have a problem with pointer to a defined type named
#typedef unsigned char TByte;
Assuming the '#' is just a typo, if this is a macro it might make a
A pointer to TByte ( e.g. "TByte* naData") is represented with 4 Bytes
in the case of multibyte and with 8 Bytes in the case of unicode.
No. The size of a pointer is a platform-specific thing and typically 4 bytes
on 32 bit platforms and 8 bytes on 64 bit platforms. The distinction
between "UNICODE" and "MBCS" only affects the win32 API (TCHAR and related
things) and not such fundamental things as pointer sizes.
My problem is that I have to send Data to an other programm that can
only interpret the Multibyte form.
How can I define TByte* so that it is represented with 4 Byte?
First thing you need to find out is what this "multibyte" really means. The
problem is that this term is not a precise definition, it only means that
texts are stored in chars and a single character (letter, glyph, grapheme)
can be represented in by than one of them. In particular, it doesn't define
what a char means, that is still up to the charset/encoding.
Note: if the encoding isn't completely fixed yet, I'd go for UTF-8 because
it is standardised, allows the complete Unicode range and is also used in
Secondly, you need to convert the internally used representation for text to
the one expected by that other program. In the case of TCHAR under CE, that
encoding is UTF-16, which should be straightforward to convert to UTF-8,
but you need to take care of surrogate sequences. For other win32
platforms, I'd suggest you also use the "UNICODE" variant of the API and
either drop support for DOS-based systems or use the compatibility
Note that much of this information is very specific to the two platforms you
are using and thus better discussed in a group dedicated to those.
Sator Laser GmbH
Gesch??ftsf??hrer: Ronald Boers, Amtsgericht Hamburg HR B62 932
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]