How to compare Unicode strings in Javascript?

后端 未结 6 2025
不知归路
不知归路 2020-11-29 21:34

When I wrote in JavaScript \"Ł\" > \"Z\" it returns true. In Unicode order it should be of course false. How to fix this? My site i

6条回答
  •  离开以前
    2020-11-29 22:05

    You have to keep two sortkey strings. One is for primary order, where German ä=a (primary a->a) and French é=e (primary sortkey e->e) and one for secondary order, where ä comes after a (translating a->azzzz in secondary key) or é comes after e (secondary key e->ezzzz). Especially in Czech some letters are variations of a letter (áéí…) whereas others stand in their full right in the list (ABCČD…GHChI…RŘSŠT…). Plus the problem to consider digraphs a single letters (primary ch->hzzzz). No trivial problem, and there should be a solution within JS.

提交回复
热议问题