jerryscript-project / jerryscript

Ultra-lightweight JavaScript engine for the Internet of Things.
https://jerryscript.net
Apache License 2.0
6.88k stars 666 forks source link

Inconsistent behavior in localeCompare #5075

Open Georgezxh opened 1 year ago

Georgezxh commented 1 year ago

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

matetokodi commented 1 year ago

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.

zherczeg commented 12 months ago

An icu would increase the library size too much.