Skip to content

Instantly share code, notes, and snippets.

@fffaraz
Created June 29, 2014 11:23
Show Gist options
  • Save fffaraz/05e3982a4bceee5c2a5e to your computer and use it in GitHub Desktop.
Save fffaraz/05e3982a4bceee5c2a5e to your computer and use it in GitHub Desktop.
farsi.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<p><textarea rows="15" cols="100" id="src"></textarea></p>
<p><textarea rows="15" cols="100" id="dest" dir="rtl"></textarea></p>
<button onclick="myFunction()">Convert</button>
<script>
function myFunction()
{
var str = document.getElementById("src").value;
var res = str;
res = res.split("[B]").join("►");
for (var i = 0; i < 1000; i++)
{
res = res.replace("q", "ض");
res = res.replace("w", "ص");
res = res.replace("e", "ث");
res = res.replace("r", "ق");
res = res.replace("t", "ف");
res = res.replace("y", "غ");
res = res.replace("u", "ع");
res = res.replace("i", "ه");
res = res.replace("o", "خ");
res = res.replace("p", "ح");
res = res.replace("[", "ج");
res = res.replace("]", "چ");
res = res.replace("a", "ش");
res = res.replace("s", "س");
res = res.replace("d", "ی");
res = res.replace("f", "ب");
res = res.replace("g", "ل");
res = res.replace("h", "ا");
res = res.replace("j", "ت");
res = res.replace("k", "ن");
res = res.replace("l", "م");
res = res.replace(";", "ک");
res = res.replace("'", "گ");
res = res.replace("z", "ظ");
res = res.replace("x", "ط");
res = res.replace("c", "ز");
res = res.replace("v", "ر");
res = res.replace("b", "ذ");
res = res.replace("n", "د");
res = res.replace("m", "ئ");
res = res.replace(",", "و");
res = res.replace("\\", "پ");
res = res.replace("C", "ژ");
res = res.replace("H", "آ");
res = res.replace("(", ")");
res = res.replace(")", "(");
res = res.replace("?", "؟");
}
document.getElementById("dest").value = res;
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment