I am calling a .txt file from a jquery ajax call. It has some special characters like ±. This ± is a delimiter for a set of array; data I want to split out and push into a JavaScript array.
It is not treated as ± symbol when interpreted like this.
How do I get that data as just like browser content?
Why don't you encode your text file using JSON ? Much more easier, as it already is javascript.
Use JQuery's getJSON() method, and the file contents will directly be parsed into an array.
you could use the escape() value to split a string. for ± i found two values (maybe there are more?).
var string = escape('test±test2±test3');
var split = string.split('%C2%B1');
alert(split); // test,test2,test3
// %B1%0A is the value i found for ±
// %C2%B1 is the value escape() gives me when i just copy and paste that char :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With