问题
I want to put Å, Ä and Ö. And then compare them using html text. For example text has these characters, and i want to compare my text using javascript array. I am trying to make javascript array using following line of code:
var array = ['Å', 'Ä', 'Ö'];
i even tried Å Ä and Ö. These codes work for html but not javascript. How can i do that? thanks in advance.
回答1:
Instead of storing string literals in the array, store their unicode representations:
var myArray = ['\u197', '\u196', '\u214'];
I used this website to convert your ASCII symbols to unicode.
回答2:
If your Javascript code is in a separate file than your HTML, you'll need to make sure that all of your files are using the same character encoding (e.g. utf-8). If you are using literals like this, you'll have to force your editor to use the correct encoding.
What editor are you using?
来源:https://stackoverflow.com/questions/12283369/how-to-put-%c3%85-%c3%84-and-%c3%96-in-a-javascript-array-and-then-compare-it-with-html-text