jerryscript icon indicating copy to clipboard operation
jerryscript copied to clipboard

Inconsistent behavior in localeCompare

Open Georgezxh opened this issue 2 years ago • 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

Georgezxh avatar Apr 21 '23 13:04 Georgezxh

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.

matetokodi avatar Jun 28 '23 14:06 matetokodi

An icu would increase the library size too much.

zherczeg avatar Jul 18 '23 04:07 zherczeg