Created
April 19, 2016 09:10
-
-
Save meysampg/41bdc155511a7e03090b7922a6ca50f9 to your computer and use it in GitHub Desktop.
Convert a mis-layouted persian string to readable one
This file contains 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
var msg = 'hdk d; k,aji thvsd hsj'; | |
var engPerLet = { | |
' ': ' ', | |
'a': 'ش', | |
's': 'س', | |
'd': 'ی', | |
'f': 'ب', | |
'g': 'ل', | |
'h': 'ا', | |
'j': 'ت', | |
'k': 'ن', | |
'l': 'م', | |
';': 'ک', | |
'q': 'ض', | |
'w': 'ص', | |
'e': 'ث', | |
'r': 'ق', | |
't': 'ف', | |
'y': 'غ', | |
'u': 'ع', | |
'i': 'ه', | |
'o': 'خ', | |
'p': 'ح', | |
'[': 'ج', | |
']': 'چ', | |
'z': 'ظ', | |
'x': 'ط', | |
'c': 'ز', | |
'v': 'ر', | |
'b': 'ذ', | |
'n': 'د', | |
'm': 'پ', | |
',': 'و', | |
'.': '.', | |
'M': 'ء' | |
}; | |
str = ''; | |
for (i = 0; i < msg.length; ++i) { | |
str += engPerLet[msg[i]]; | |
} | |
alert(str); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment