简体   繁体   中英

Javascript Html Swedish characters strange behavior

I would like to ask a question regarding a strange behavior I face using the escape Ascii characters for some Swedish chars.

More specifically, in order to support a multilingual site, I have a json file where I have specified all required messages in Swedish, ie 'Avancerad s& #246 ;k'.

Then when the page loads the first time, I set this value to an input text and it is displayed properly: 'Avancerad sök'. But when I click a button and set again the value of this input text I get: 'Avancerad s& #246 ;k'.

Does anyone have faced a similar problem?

Thanks a lot!

Code:

q('#keyword').val(qLanguage.qAdvancedHint);

I execute this code both times. qLanguage is an object which I fill it from the json file and qAdvancedHint a specific key.

Don't know have the specific encoding is called. But tested with js's unescape method, but didn't work.

However a solution, a bad/ugly one, could be to ask jQuery to parse it for you then add it as a value property:

var text = $("<span/>").html(qLanguage.qAdvancedHint).text();
q('#keyword').val(text);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM