JavaScript Unicode normalization

前端 未结 4 2056
执念已碎
执念已碎 2020-12-16 14:33

I\'m under the impression that JavaScript interpreter assumes that the source code it is interpreting has already been normalized. What, exactly does the normalizing? It can

4条回答
  •  孤街浪徒
    2020-12-16 14:54

    I've updated @bobince 's answer:

    var cafe4= 'caf\u00E9';
    var cafe5= 'cafe\u0301';
    
    
    console.log (
      cafe4+' '+cafe4.length,                  // café 4
      cafe5+' '+cafe5.length,                  // café 5
      cafe4 === cafe5,                         // false
      cafe4.normalize() === cafe5.normalize()  // true
    );
    

提交回复
热议问题