A couple questions about multibyte strings...

Do all the characters in the same encoding use the same number of bytes per
character, or is it possible for an encoding to use 3 bytes for one
character, 1 for another, etc?
The latter. For Shift-JIS, each character consists of one or two bytes, while if you happened to be running on a (non-existent) device that used UTF-8, a character could be one, two, three, or even (though not with the current Palm OS) four bytes.

Is there a string library available anywhere for multibyte strings or does
everyone roll their own strlen,
strlen and StrLen both work fine in this case, since they return a byte count, not a character count. Note that all of the Palm OS APIs are in terms of bytes (lengths & offsets), not characters, even though some of the names would lead you to believe otherwise.

The String Mgr routines are all safe to use with multi-byte character encodings.

atoi,
StrAToI() only converts single-byte numbers. In general conversion of other numeric forms (e.g. double-byte equivalents and "native" numeric variants) isn't commonly useful.

strtok, etc?
strtok isn't part of the standard Palm OS API.

It'd be nice to see a
class for multibyte chars that overload [] and provides string.h
functionality.
Between the String Mgr and the Text Mgr, you should have most of what you need. There are some holes - for example, there's no easy way to do a case-insensitive StrStr/strstr.

-- Ken
--
Ken Krugler
<http://www.krugler.org>
+1 530-265-2225

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

Reply via email to