0

I'm using Ethplorer API to retrieve token symbol for particular address. For this purpose I use Get token info:

/getTokenInfo/{address}

In most cases I receive readable symbol but for some tokens I get unreadable ones. So the following token address I get the following symbol:

"symbol":"\ud83c\udfcb\ufe0f"

How can I decode to readable string?

1 Answer 1

1

Use this method to convert unicode format to string.

function unicodeToChar(text) {
   return text.replace(/\\u[\dA-F]{4}/gi, 
          function (match) {
               return String.fromCharCode(parseInt(match.replace(/\\u/g, ''), 16));
          });
}

for more details

https://stackoverflow.com/questions/17267329/converting-unicode-character-to-string-format/22021709

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.