Amiga CompareStr()

Report any Hollywood bugs here
Post Reply
User avatar
lazi
Posts: 363
Joined: Thu Feb 24, 2011 11:08 pm

Amiga CompareStr()

Post by lazi » Wed May 29, 2019 11:44 pm

This is ok:
CompareStr("Amiga","pc",False) /* -1 */

These two are wrong:
CompareStr("álma","alma",False) /* 0 */
CompareStr("á","a",False) /* 1 */

Should it work on Amiga (codesets.library) ?

User avatar
airsoftsoftwair
Posts: 3206
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Amiga CompareStr()

Post by airsoftsoftwair » Thu May 30, 2019 7:13 pm

Actually, this isn't wrong:

Code: Select all

CompareStr("á","a",False) /* 1 */
"á" is greater than "a" so this is right, but the other one is definitely wrong. It's fixed now. Unfortunately, codesets.library doesn't offer any collation capabilities so Hollywood uses a custom algorithm on Amiga/Linux/Android.

Code: Select all

- Fix [Amiga/Linux/Android]: Unicode sorting in CompareStr() and Sort() didn't work correctly for words
  which only differ in their diacritics 

User avatar
lazi
Posts: 363
Joined: Thu Feb 24, 2011 11:08 pm

Re: Amiga CompareStr()

Post by lazi » Sun Sep 29, 2019 9:06 pm

I wonder that why Sort and CompareStr uses different method of collation?
The 7.0 history said about this: - New: Sort() supports full Unicode collation now.

Edit:
Is it resolved by the fix you mentioned? Just realized that fix is not public yet.


Here are a simple test:

Code: Select all

SetFont(#SANS,20)

a={"abcd","ábcd","adcb"}
Sort(a)
for i,v in ipairs(a)
    nprint(i,v)
next

NPrint("")

Sort(a,CompareStr)
for i,v in ipairs(a)
    nprint(i,v)
next

WaitLeftMouse

The Sort(a) result, which is faulty:
ábcd
abcd
adcb


The Sort(a,CompareStr) result is correct:
abcd
adcb
ábcd

Other question is why drops me an "Invalid orderfunction for sorting" error when a fourth string is added to the array?
a={"abcd","ábcd","adcb","abce"}

User avatar
airsoftsoftwair
Posts: 3206
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Amiga CompareStr()

Post by airsoftsoftwair » Tue Oct 01, 2019 12:18 am

lazi wrote:
Sun Sep 29, 2019 9:06 pm
I wonder that why Sort and CompareStr uses different method of collation?
No, they don't use different methods of collation so looks there is something wrong...
lazi wrote:
Sun Sep 29, 2019 9:06 pm
Other question is why drops me an "Invalid orderfunction for sorting" error when a fourth string is added to the array?
a={"abcd","ábcd","adcb","abce"}
Yeah, there's definitely something wrong here. I'll investigate :)

Post Reply