Re: how to convert an unsigned short to an unsigned char?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Bruce Eitman \(eMVP\) (beitmannospam_at_NOSPAM_applieddata.NOSPAM_net)
Date: 01/12/05


Date: Wed, 12 Jan 2005 08:10:18 -0500

You are asking about some very basic C/C++ programming. Usually covered in
chapter 1 or 2 of a C/C++ Programming book. So I would start by learning
the language.

unsigned short Short;
unsigned char Char;

Char = (unsigned char) Short; // NOTE: You are loosing a byte of data, so
only do this if using the
                                                // unsigned short was a
mistake in the first place.

CString to unsigned char -> really can't be done and doesn't make any sense.

What I think you want to do is look into UNICODE. I suspect that you don't
know anything about UNICODE or that Windows CE uses UNICODE. So you are
trying to use char, when you should be using TCHAR.

-- 
Bruce Eitman (eMVP)
Senior Engineer
beitman AT applieddata DOT net
Applied Data Systems
 www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member


Relevant Pages

  • Re: TCHAR and buffer overflows
    ... This would be a problem if you hadn't defined UNICODE in your build. ... unsigned char *_mbsncpy(unsigned char *strDest, ... >> macro WCHAR was introduced to switch between ascii and unicode chars as ... > I think you mean TCHAR. ...
    (comp.security.misc)
  • Re: TCHAR and buffer overflows
    ... This would be a problem if you hadn't defined UNICODE in your build. ... unsigned char *_mbsncpy(unsigned char *strDest, ... >> macro WCHAR was introduced to switch between ascii and unicode chars as ... > I think you mean TCHAR. ...
    (comp.os.ms-windows.nt.admin.security)
  • support for unicode dead keys
    ... the current keyboard mapping code allows for unicode characters ... There is also a "compose" table which ... -static unsigned char handle_diacr ... +extern struct kbdiacruc accent_table; ...
    (Linux-Kernel)
  • Re: Unicode: char->TCHAR
    ... >I found that it resolved to unsigned char for both Unicode and ... Exactly - and that's what distinguishes it from TCHAR, which expands to ...
    (microsoft.public.vc.mfc)