[Vuejs]-Cannot always successfully use String.startsWith() when string contains unicode characters

2👍

You can use Intl.Collator to construct a collator that only cares about some differences:

var word1 = "anunț"; // anun\u21B
var word2 = "anunţ"; // anun\u163

var collator = new Intl.Collator("ro", { sensitivity: "base" });

console.log(word1 === word2); // the words are not equal
console.log(collator.compare(word1, word2) == 0); // ... but they are "equal enough"

1👍

These two characters are very similar, but they are distinct. One has space between the t and the lower comma mark like part of the symbol.

Leave a comment