A few notes about StrToLower and the (unimplemented) StrToUpper:

1. Prior to version 3.2 of the roms, StrToLower only operated on the
characters 'A' through 'Z'. It did nothing with upper case characters
located in the high ascii range.

2. Starting with version 3.2, StrToLower will essentially execute a call to
the new TxtTransliterate routine. This results in lower-casing of all
upper-case characters found in the complete character set, including
characters in the high ascii (0x80 to 0xFF) range.

3. TxtTransliterate is available starting with version 3.1 of the rom. The
API is:

// Transliterate <inSrcLength> bytes of text found in <inSrcText>, based
// on the requested <inOp> operation. Place the results in <outDstText>,
// and set the resulting length in <ioDstLength>. On entry <ioDstLength>
// must contain the maximum size of the <outDstText> buffer. If the
// buffer isn't large enough, return an error (note that outDestText
// might have been modified during the operation). Note that if <inOp>
// has the preprocess bit set, then <outDstText> is not modified, and
// <ioDstLength> will contain the total space required in the destination
// buffer in order to perform the operation; no buffer space error will be
// generated

Err TxtTransliterate(ConstCharPtr inSrcText, Word inSrcLength, CharPtr
outDstText,
                        WordPtr ioDstLength, TranslitOpType inOp);

The two universally defined values for TranslitOpType are:

#define translitOpUpperCase             0
#define translitOpLowerCase             1

Thus it can be used to handle upper-casing of text.

4. I believe Daniel's theory about the absence of StrToUpper is
correct...the Palm OS API was originally spec'd to only consist of those
routines required by the built-in apps and the OS, thus orthogonality was
punted in favor of getting a product shipped sooner.

5. Several people posted code to implement the StrToUpper funcationality.
As was pointed out, the code listings provided would not handle non-Latin
character encodings. Your three choices for correct transliteration are:

a. Use TxtTransliterate. Unfortunately it's not available on pre-3.1 roms.

b. Link with the IntlGlue.lib library, and use TextTransliterate.
Unfortunately the 3.1 SDK (which includes this library file) isn't out the
door yet.

c. Roll your own, which checks the rom version and then calls
TxtTransliterate or your own routine.

6. If you opt for 5c, then you'd either want to use a 256 byte lookup table
(for speed) or have a somewhat massive if statement such as (not tested!!!):

if ((ch >= chrSmall_A) && (ch <= chrSmall_Z)) {
        ch -= (chrSmall_A - chrCapital_A);
} else if (ch == chrSmall_S_Caron) {
        ch -= (chrSmall_S_Caron - chrCapital_S_Caron);
} else if (ch == chrSmall_OE) {
        ch -= (chrSmall_OE - chrCapital_OE);
} else if ((ch >= chrSmall_A_Grave) && (ch <= chrSmall_Thorn)) {
        ch -= (chrSmall_A_Grave - chrCapital_A_Grave);
}

-- Ken

Ken Krugler
TransPac Software, Inc.
<http://www.transpac.com>
+1 650-947-9222 (direct) +1 408-261-7550 (main)


Reply via email to