# encoding: utf-8

def enToPersianNumb(number):
    numPersian = ['۰','۱','۲','۳','۴','۵','۶','۷','۸','۹','.']
    numEnglish = ['0','1','2','3','4','5','6','7','8','9','.']
    return replaceing(numEnglish, numPersian, number)

def enToPersianchar(userInput):
    charPersian = [ 'ض', 'ص', 'ث', 'ق', 'ف', 'غ', 'ع', 'ه', 'خ', 'ح', 'ج', 'چ', 'ش', 'س', 'ی', 'ب', 'ل', 'ا', 'ت', 'ن', 'م', 'ک', 'گ', 'ظ', 'ط', 'ز', 'ر', 'ذ', 'د', 'پ', 'و','؟' ]
    charEnglish = [ 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', "'", 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',','?' ]
    return replaceing(charEnglish, charPersian, userInput)

def arToPersianNumb(number):
    numArabic = ['١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩', '٠']
    numPersian = ['۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', '۰']
    return replaceing(numArabic, numPersian, number)

def arToPersianChar(userInput):
    charArabic = ['ي', 'ك', '‍', 'دِ', 'بِ', 'زِ', 'ذِ', 'ِشِ', 'ِسِ', '‌', 'ى']
    charPersian = ['ی', 'ک', '', 'د', 'ب', 'ز', 'ذ', 'ش', 'س', '', 'ی']
    return replaceing(charArabic, charPersian, userInput)
    
#list 1 is or  not ok host
#list 2 is or ok dest

def replaceing(host, dest, input):
    
    returnList = list()

    for i in list(unicode(input)):
        if i in host:
            returnList.append(dest[host.index(i)])
        else:
            returnList.append(i)
    
    return ''.join(returnList)
 

print enToPersianNumb('شماره کلاس 312')
print enToPersianNumb(3123123.9012)
print enToPersianNumb(123)
print enToPersianchar('sghl ]i ofv')
print arToPersianNumb('٣٤٥٦')
print arToPersianChar(' ك جمهوري اسلامي ايران')





@@ -11,16 +11,214 @@
 : utf-8%0A
+'''%0Apersian.py%0AA simple library for Persian language localization in Python%0ACopyright (C) 2013 Mohammad reza Kamalifard , kamalifard@datasec.ir%0AMIT licensed%0Ahttps://github.com/itmard/persian.py %0A'''
 %0Adef enT
@@ -1648,229 +1648,4 @@
 st)%0A
- %0A%0Aprint enToPersianNumb('%D8%B4%D9%85%D8%A7%D8%B1%D9%87 %DA%A9%D9%84%D8%A7%D8%B3 312')%0Aprint enToPersianNumb(3123123.9012)%0Aprint enToPersianNumb(123)%0Aprint enToPersianchar('sghl %5Di ofv')%0Aprint arToPersianNumb('%D9%A3%D9%A4%D9%A5%D9%A6')%0Aprint arToPersianChar(' %D9%83 %D8%AC%D9%85%D9%87%D9%88%D8%B1%D9%8A %D8%A7%D8%B3%D9%84%D8%A7%D9%85%D9%8A %D8%A7%D9%8A%D8%B1%D8%A7%D9%86')%0A%0A%0A%0A%0A

remove test from toPersian.py