Hi,
There was a similar query posted by Aaron Ardiri on Nov. 30, but I couldn't
find any reply in the archives. So, I am posting this. Can the guys from
Palm give it a go?
It seems Palm OS string comparisons are not always based on ANSI codes.
e.g.,
StrCompare(" ", "-") or StrCaselessCompare(" ", "-") returns a value > 0.
The ANSI code for [space] is 32 and ANSI code for - is 45. So, I expected
that the above two calls will return a value < 0. That's what happens if I
use strcmp or _stricmp in a VC++ 6.0 program.
Can anybody from Palm tell me how StrCompare and StrCaselessCompare works in
Palm OS and why? I am sorting my data in the PC (it's faster). But when I
send the data to the Palm device, binary search fails as the data is not
sorted according to its sorting rule.
I have confirmed this by checking the array returned by
GetCharCaselessValue. For [space] it stores 41 and for - it stores 37.
The documentation for GetCharCaselessValue is interesting:
"BytePtr GetCharCaselessValue (void)
Parameters None.
Result Returns a pointer to the sort array.
The compiler pads each byte out to a word so each index position
contains two characters.
Note: array[x].high = sort value for character 2x+1."
If its returning a byte pointer, why do we have to worry about word
alignment? We can always access any byte we want. The StrCmpMatches function
in the Addressbook example exactly does that.
"The GetCharCaselessValue conversion table converts each
character into a numeric value that is caseless and sorted according
to Microsoft Windows sorting rules:
� Punctuation characters have the lowest values,
� followed by numbers,
� followed by alpha characters.
All forms of each alpha character have equivalent values, so
that e = E = e-grave = e-circumflex, etc.
This conversion table is used by all the Palm OS sorting and
comparison routines to yield caseless searches and caseless sorts in
the almost same order as Windows-based programs, except that
^^^^^^
Palm OS routines produce the same sorting for all locales."
What does this "almost" means?
The documentation for GetCharSortValue says:
"BytePtr GetCharSortValue (void)
Parameters None.
Result Returns a pointer to the attributes array. This is an array of 256
Word
values, one for each possible character code.
The compiler pads each byte out to a word so each index position
contains two characters.
NOTE: array[x].low = sort value for character 2x."
I am li'l lost here. If it is returning an array of 256 word values, why the
compiler has to pad? If we put 2 chars in a word we get 512 chracters. Do
Palm OS have that many characters? What am I missing here?
Happy holidays and a great new year to you all :).
-Sugho-
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com