unicode and python issue (access to unicde code charts)
Yesterday i wrote the following function to convert integer to Persian :
def integerToPersian(number):
listedPersian =
['۰','۱','۲','۳','۴','۵','۶','۷','۸','۹']
listedEnglish = ['0','1','2','3','4','5','6','7','8','9']
returnList = list()
listedTmpString = list(str(number))
for i in listedTmpString:
returnList.append(listedPersian[listedEnglish.index(i)])
return ''.join(returnList)
When you call it such as : integerToPersian(3455) , it return
۳۴۵۵, ۳۴۵۵ is equivalent
to 3455 in Persian and Arabic language.When you read a number such as
reading from databae, and want to show in widget, this function is very
useful.
I downloaded codes charts of unicode from http://unicode.org ,Because i
need to wrote PersianToInteger('unicodeString') According to it should get
utf-8 as parameter and utf-8 store 2 bytes,Also i'm newbie in pytho.
My questions are, how can store 2bytes? , how can utf8 store , how can
split an unicode string to another format ? how can use unicode code
charts?
Notes: I found to use int() built-in fuinction , but i couldn't use it.may
be you can
No comments:
Post a Comment