I embedded a short script into a client's website which is grabbing text feed content from a 3rd party. The result is 5 links encoded in ISO8859-1. Since the whole website has UTF-8 French content, this feed is creating artifacts.
Is there any way to use JavaScript / jQuery to convert the ISO feed to UTF and then display everything on the website properly?
Thanks!
EDIT
The solution in my case was actually easy. All I have done was to add charset='ISO8859-1'
into the JavaScript that was pulling news feed. I hope this will help someone.
UTF-8 is a multibyte encoding that can represent any Unicode character. ISO 8859-1 is a single-byte encoding that can represent the first 256 Unicode characters. Both encode ASCII exactly the same way.
byte[] utf8 = ... byte[] latin1 = new String(utf8, "UTF-8"). getBytes("ISO-8859-1"); You can exercise more control by using the lower-level Charset APIs. For example, you can raise an exception when an un-encodable character is found, or use a different character for replacement text.
UTF-8 encodes a character into a binary string of one, two, three, or four bytes. UTF-16 encodes a Unicode character into a string of either two or four bytes. This distinction is evident from their names. In UTF-8, the smallest binary representation of a character is one byte, or eight bits.
PHP | utf8_encode() Function The utf8_encode() function is an inbuilt function in PHP which is used to encode an ISO-8859-1 string to UTF-8. Unicode has been developed to describe all possible characters of all languages and includes a lot of symbols with one unique number for each symbol/character.
Add charset='ISO8859-1'
into the JavaScript that pulls the news feed.
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