Skip to content
Advertisement

How to convert Unicode Hex Characters to Latin-1 in JavaScript

I’m using rae-api to get the definition of the words in their dictionary. The problem is for example: I search for the definition of the word hola, it returns como salutación familiar.. I want to get the value of ó in Latin-1 characters: ó, therefore, the result would be como salutación familiar.

getHex function removes &#; and returns xF3 to the text. However, i want to convert all Unicode Hex characters to Latin-1.

I have tested a lot of answers in similar problems, but none of they works for me (example: decodeURIComponent or using Hex to utf8 libraries). I’m using Discord.js.

userInput is the word to search for

JavaScript

Advertisement

Answer

JavaScript
Advertisement