1

I need to convert an ASCII string to UTF-8 with javascript.

So the following raw ASCII strings:

imagᅢᄄ-thrᅢ랡.png
imᅢᄂge-twᅢᄊ.png
ᅢᆲmᅢᄀgᅢᄅ-fᅢ배ᄏr.png

Needs to be converted to:

imäge-twö.png
imagè-thréê.png
ìmágé-fòûr.png

I can do it with this online utility (so it's possible!). Looking for a way to do it with a javascript function.

1
  • In Node.js: Buffer.from(text, 'ascii').toString() Commented Sep 18, 2022 at 9:31

1 Answer 1

1

You can actually use this utf-8 library for that. If you are using plain javaScript you need to save the utf-8.js file and use it in <script src=""> tag. Then you can useutf8.decode() function. Something like:

<body>
    <script src="./utf-8.js"></script>
    <script>
        console.log(utf8.decode('imagᅢᄄ-thrᅢ랡.png'))
        console.log(utf8.decode('imᅢᄂge-twᅢᄊ.png'))
        console.log(utf8.decode('ᅢᆲmᅢᄀgᅢᄅ-fᅢ배ᄏr.png'))
    </script>
</body>
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! This did the trick!

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.