At 12:00am -0700 00-07-12, Palm Developer Forum digest wrote:
>Subject: RE: StrIToA
>From: "McMicken, Steven" <[EMAIL PROTECTED]>
>Date: Tue, 11 Jul 2000 15:15:51 -0400
>X-Message-Number: 75
>
>PalmTypes.h defines Char as type char so there is no difference in their
>use.  For localization, I believe you should use type WChar, which is
>defined as UInt16 (or unsigned short).

Actually strings are still sequences of bytes, even when the device's 
character encoding is Shift-JIS (Japanese). You'd declare a string 
variable as:

        Char myString[kMaxStringLength+1];

The WChar type is useful for those less-common situations where you 
need to process individual characters. For example, to snag every 
character from a string, one at a time, you'd do something like:

        const Char* tempP = myString;
        do {
                WChar curChar;
                tempP += TxtGetNextChar(tempP, 0, &curChar);
                // do something with curChar
        } while (curChar != chrNull);

Also note that the keydown event contains a WChar, not a Char, so if 
you need to pass that around in your program, use WChar function 
parameters so that you don't wind up stripping the high byte of the 
character code.

Finally, proper use of the WChar type and the Text Mgr routines is 
good Palm programming, not just "for localization". The goal is for 
all software to run properly on all devices, regardless of the 
device's character set. There are rare cases where you have to code 
specifically for ASCII/Latin, but those are few and far between.

-- Ken

Ken Krugler
TransPac Software, Inc.
<http://www.transpac.com>
+1 530-470-9200

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to