Created
December 13, 2023 12:23
-
-
Save yonixw/1685a743862bfd0feccc4724c641ef30 to your computer and use it in GitHub Desktop.
JS convert windows 1255 (hebrew) to utf8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const win1255 = [ | |
..."àýáýâýãýäýåýæýçýèýéýëýêìýîýðýñýòýôýöý÷ýøýùýúíýïóýõáÌâÌãÌëÌêÌôÌóÌùÑùÒúÌ×ÈýÇýÂÅýÆýÁÉýÃËÌÄåÌ", | |
].filter((e) => e != "ý"); | |
const hebutf8 = [ | |
..."אבגדהוזחטיכךלמנסעפצקרשתםןףץבּגּדּכּךּפּףּשׁשׂתּ׳ֱֲֳִֵֶַָֹֻּוּ", | |
].filter((e) => !!e && e.charCodeAt(0) != 8206); | |
function win1255toUTF(str) { | |
return [...str] | |
.map((e) => (win1255.indexOf(e) > -1 ? hebutf8[win1255.indexOf(e)] : e)) | |
.join(""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment