How to translate Arabic/Persian numbers to english using Ruby?
问题 How can I convert some string that has Arabic/Persian number to English ? Like if I have : str1 = "١۲١۲" str2 = "12١۲" str3 = "some string that contains persian digits like ١۲" Is there any function to encode it to english, and if the string contain such number to convert it like end results will be : str1 = "1212" str2 = "1212" str3 = "some string that contains persian digits like 12" Thanks 回答1: For these one on one transformations the tr-method is very convenient and fast. It has a