jerryscript-project/jerryscript

Inconsistent behavior in localeCompare

Georgezxh opened this issue · 2 comments

JerryScript revision

2.4.0

Description

'a' is before 'A', so the first result should be negative number.
When adding parameter{ sensitivity: 'base' }, 'a' should be equal 'A', so the second result should be 0.

Test case

var a = 'a'; 
var b = 'A'; 
print(a.localeCompare(b));
print(a.localeCompare(b, 'en', { sensitivity: 'base' }));

Output

1
1

Expected behavior

-1(Or other negative number)
0

Fixing this would require the use of libICU or a similar library for proper unicode and locale support, which would increase the size of the jerryscript binary substantially, and as such it will not be done.

An icu would increase the library size too much.