Skip to content

Instantly share code, notes, and snippets.

@yonixw
Created December 13, 2023 12:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yonixw/1685a743862bfd0feccc4724c641ef30 to your computer and use it in GitHub Desktop.
Save yonixw/1685a743862bfd0feccc4724c641ef30 to your computer and use it in GitHub Desktop.
JS convert windows 1255 (hebrew) to utf8
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