When I parse the XML, it contains abnormal hex characters. So I tried to replace it with empty space. But it doesn't work at all.
Original character : �
hex code : (253, 255)
code :
xmlData = String.replace(String.fromCharCode(253,255)," ");
retrun xmlData;
I'd like to remove "ýÿ" characters from description. Is there anyone who have a trouble with replacing hex character to empty space?
Based on the answers, I've modified the code as follows:
testData = String.fromCharCode(253,255);
xmlData = xmlData.replace(String.fromCharCode(253,255), " ");
console.log(xmlData);
but it still shows '�' on the screen..
Do you know why this still happens?
The replace() method searches a string for a value or a regular expression. The replace() method returns a new string with the value(s) replaced.
The String. fromCharCode() method converts Unicode values to characters. The String. fromCharCode() is a static method of the String object.
The JavaScript replace() method is used to replace any occurrence of a character in a string or the entire string. It searches for a string corresponding to either a particular value or regular expression and returns a new string with the modified values.
The character code is actually 255 * 256 + 253 = 65533, so you would get something like this:
xmlData = xmlData.replace(String.fromCharCode(65533)," ");
String String.fromCharCode(253,255)
is of two characters.
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