I want to first encode a JSON String (it has some Arabic words) and then decode it in my JavaScript file.
PS: This piece of code works fine if the JSON String has only English Words. But I want it to work for Arabic Words also.
Encoding:
<input type="hidden" id="cei-nav-urlparam-ceiIndex" value='<%= URLEncoder.encode(ceiIndexTree, "UTF-8") %>' />
Decoding:
this.initFiltersValues = function(ceinavUrlPara) {
ceinavUrlParams = unescape(ceinavUrlPara);
ceinavUrlParams = ceinavUrlParams.replace(/\+/g, " ");
var res = $.parseJSON(ceinavUrlParams);
console.log('INITIAL FILTER FROM URL: '+ceinavUrlParams);
return res;
};
Using UTF-8 solves the purpose instead of ISO-8859-1.