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.
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 use utf8.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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.