>     I am writing an app that needs to search through the Palm phone book. 
>     It uses a binary search and uses TxtCaselessCompare for the comparison 
>     operator. 
>     
>     I am getting incorrect results from TxtCaselessCompare when using a 
>     mixture or ASCII string and MBCS strings. 
>     
>     My phonebook order is 
>     
>     aaa
>     bbb
>     ccc
>     <Hirigana a>
>     <Hirigana i>
>     <Hirigana u>
>     <Hirigana e>
>     <Hirigana o>
>     
>     
>     When I call 
>        TxtCaselessCompare ("b", <Hirigana i>,...);
>     
>     it returns 1 instead of -1.

Here's the declaration for TxtCaselessCompare:

Int16 TxtCaselessCompare(const Char* s1, UInt16 s1Len, UInt16 * s1MatchLen,
                        const Char* s2, UInt16 s2Len, UInt16 * s2MatchLen)

Based on your code snippet, it looks like you might be passing the pointer to the 
Hiragana i as the s1MatchLen parameter, versus the s2 parameter. For the code snippet 
to really match up with the real API, it would have to be:

        Int16 result = TxtCaselessCompare("b", 1, NULL, "Ǣ", 2, NULL);

I also checked the sort order in my test app, and it sorts single-byte before 
double-byte by default.

-- Ken

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


Reply via email to