Last active
September 30, 2018 21:52
-
-
Save MohamedAmrMahdy/d76840f86f0106754988302d6a77f74b to your computer and use it in GitHub Desktop.
Convert Arabic words from LTR to RTL
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
function arabicFixerRTL(inputString){ | |
let words = inputString.split(" "); | |
let final = ""; | |
for (var i = 0; i < words.length ; i++) { | |
if(words[i].charCodeAt(0) > 1535 && words[i].charCodeAt(0) < 1792){ | |
final += words[i].split("").reverse().join("") + " "; | |
}else{ | |
final += words[i] + " "; | |
} | |
} | |
return final.split(" ").reverse().join(" "); | |
} |
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
function arabicFixerRTL(inputString){ | |
let words = inputString.split(" "); | |
let final = ""; | |
for (var i = 0; i < words.length ; i++) { | |
if(words[i].charCodeAt(0) > 1535 && words[i].charCodeAt(0) < 1792){ | |
final += Reshaper.reshape(words[i]).split("").reverse().join("") + " "; | |
}else{ | |
final += words[i] + " "; | |
} | |
} | |
return final.split(" ").reverse().join(" "); | |
} |
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
https://github.com/mapmeld/js-arabic-reshaper | |
https://github.com/louy/Javascript-Arabic-Reshaper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment