.. post:: 2016-03-08 :tags: python, unicode :category: Python :excerpt: 1 More Than Just ASCII Digits =========================== Python's `int()` converts more than just ASCII digits. It also converts decimal digits from other scripts. >>> int('42') 42 >>> int(u'୨୩') 23 It's also possible to mix differnt scripts. `int()` only cares about the decimal value of each digit character. >>> int(u'௧౩౩೭') 1337 The following snippet creates CSV data for all digits `int()` can convert: .. code-block:: python #!/usr/bin/env python # coding: utf8 from __future__ import absolute_import, division, print_function import sys import unicodedata def main(): for i in xrange(sys.maxunicode + 1): try: character = unichr(i) value = int(character) except ValueError: pass else: print( u'{0},{1},{2:x},{3}'.format( character, value, i, unicodedata.name(character).lower() ).encode('utf8') ) if __name__ == '__main__': main() And here's the table generated by that script: .. csv-table:: All digits Python 2.7's `int()` converts. :header: Character,Value,Codepoint (hex),Name :widths: 1,1,1,10 0,0,30,digit zero 1,1,31,digit one 2,2,32,digit two 3,3,33,digit three 4,4,34,digit four 5,5,35,digit five 6,6,36,digit six 7,7,37,digit seven 8,8,38,digit eight 9,9,39,digit nine ٠,0,660,arabic-indic digit zero ١,1,661,arabic-indic digit one ٢,2,662,arabic-indic digit two ٣,3,663,arabic-indic digit three ٤,4,664,arabic-indic digit four ٥,5,665,arabic-indic digit five ٦,6,666,arabic-indic digit six ٧,7,667,arabic-indic digit seven ٨,8,668,arabic-indic digit eight ٩,9,669,arabic-indic digit nine ۰,0,6f0,extended arabic-indic digit zero ۱,1,6f1,extended arabic-indic digit one ۲,2,6f2,extended arabic-indic digit two ۳,3,6f3,extended arabic-indic digit three ۴,4,6f4,extended arabic-indic digit four ۵,5,6f5,extended arabic-indic digit five ۶,6,6f6,extended arabic-indic digit six ۷,7,6f7,extended arabic-indic digit seven ۸,8,6f8,extended arabic-indic digit eight ۹,9,6f9,extended arabic-indic digit nine ߀,0,7c0,nko digit zero ߁,1,7c1,nko digit one ߂,2,7c2,nko digit two ߃,3,7c3,nko digit three ߄,4,7c4,nko digit four ߅,5,7c5,nko digit five ߆,6,7c6,nko digit six ߇,7,7c7,nko digit seven ߈,8,7c8,nko digit eight ߉,9,7c9,nko digit nine ०,0,966,devanagari digit zero १,1,967,devanagari digit one २,2,968,devanagari digit two ३,3,969,devanagari digit three ४,4,96a,devanagari digit four ५,5,96b,devanagari digit five ६,6,96c,devanagari digit six ७,7,96d,devanagari digit seven ८,8,96e,devanagari digit eight ९,9,96f,devanagari digit nine ০,0,9e6,bengali digit zero ১,1,9e7,bengali digit one ২,2,9e8,bengali digit two ৩,3,9e9,bengali digit three ৪,4,9ea,bengali digit four ৫,5,9eb,bengali digit five ৬,6,9ec,bengali digit six ৭,7,9ed,bengali digit seven ৮,8,9ee,bengali digit eight ৯,9,9ef,bengali digit nine ੦,0,a66,gurmukhi digit zero ੧,1,a67,gurmukhi digit one ੨,2,a68,gurmukhi digit two ੩,3,a69,gurmukhi digit three ੪,4,a6a,gurmukhi digit four ੫,5,a6b,gurmukhi digit five ੬,6,a6c,gurmukhi digit six ੭,7,a6d,gurmukhi digit seven ੮,8,a6e,gurmukhi digit eight ੯,9,a6f,gurmukhi digit nine ૦,0,ae6,gujarati digit zero ૧,1,ae7,gujarati digit one ૨,2,ae8,gujarati digit two ૩,3,ae9,gujarati digit three ૪,4,aea,gujarati digit four ૫,5,aeb,gujarati digit five ૬,6,aec,gujarati digit six ૭,7,aed,gujarati digit seven ૮,8,aee,gujarati digit eight ૯,9,aef,gujarati digit nine ୦,0,b66,oriya digit zero ୧,1,b67,oriya digit one ୨,2,b68,oriya digit two ୩,3,b69,oriya digit three ୪,4,b6a,oriya digit four ୫,5,b6b,oriya digit five ୬,6,b6c,oriya digit six ୭,7,b6d,oriya digit seven ୮,8,b6e,oriya digit eight ୯,9,b6f,oriya digit nine ௦,0,be6,tamil digit zero ௧,1,be7,tamil digit one ௨,2,be8,tamil digit two ௩,3,be9,tamil digit three ௪,4,bea,tamil digit four ௫,5,beb,tamil digit five ௬,6,bec,tamil digit six ௭,7,bed,tamil digit seven ௮,8,bee,tamil digit eight ௯,9,bef,tamil digit nine ౦,0,c66,telugu digit zero ౧,1,c67,telugu digit one ౨,2,c68,telugu digit two ౩,3,c69,telugu digit three ౪,4,c6a,telugu digit four ౫,5,c6b,telugu digit five ౬,6,c6c,telugu digit six ౭,7,c6d,telugu digit seven ౮,8,c6e,telugu digit eight ౯,9,c6f,telugu digit nine ೦,0,ce6,kannada digit zero ೧,1,ce7,kannada digit one ೨,2,ce8,kannada digit two ೩,3,ce9,kannada digit three ೪,4,cea,kannada digit four ೫,5,ceb,kannada digit five ೬,6,cec,kannada digit six ೭,7,ced,kannada digit seven ೮,8,cee,kannada digit eight ೯,9,cef,kannada digit nine ൦,0,d66,malayalam digit zero ൧,1,d67,malayalam digit one ൨,2,d68,malayalam digit two ൩,3,d69,malayalam digit three ൪,4,d6a,malayalam digit four ൫,5,d6b,malayalam digit five ൬,6,d6c,malayalam digit six ൭,7,d6d,malayalam digit seven ൮,8,d6e,malayalam digit eight ൯,9,d6f,malayalam digit nine ๐,0,e50,thai digit zero ๑,1,e51,thai digit one ๒,2,e52,thai digit two ๓,3,e53,thai digit three ๔,4,e54,thai digit four ๕,5,e55,thai digit five ๖,6,e56,thai digit six ๗,7,e57,thai digit seven ๘,8,e58,thai digit eight ๙,9,e59,thai digit nine ໐,0,ed0,lao digit zero ໑,1,ed1,lao digit one ໒,2,ed2,lao digit two ໓,3,ed3,lao digit three ໔,4,ed4,lao digit four ໕,5,ed5,lao digit five ໖,6,ed6,lao digit six ໗,7,ed7,lao digit seven ໘,8,ed8,lao digit eight ໙,9,ed9,lao digit nine ༠,0,f20,tibetan digit zero ༡,1,f21,tibetan digit one ༢,2,f22,tibetan digit two ༣,3,f23,tibetan digit three ༤,4,f24,tibetan digit four ༥,5,f25,tibetan digit five ༦,6,f26,tibetan digit six ༧,7,f27,tibetan digit seven ༨,8,f28,tibetan digit eight ༩,9,f29,tibetan digit nine ၀,0,1040,myanmar digit zero ၁,1,1041,myanmar digit one ၂,2,1042,myanmar digit two ၃,3,1043,myanmar digit three ၄,4,1044,myanmar digit four ၅,5,1045,myanmar digit five ၆,6,1046,myanmar digit six ၇,7,1047,myanmar digit seven ၈,8,1048,myanmar digit eight ၉,9,1049,myanmar digit nine ႐,0,1090,myanmar shan digit zero ႑,1,1091,myanmar shan digit one ႒,2,1092,myanmar shan digit two ႓,3,1093,myanmar shan digit three ႔,4,1094,myanmar shan digit four ႕,5,1095,myanmar shan digit five ႖,6,1096,myanmar shan digit six ႗,7,1097,myanmar shan digit seven ႘,8,1098,myanmar shan digit eight ႙,9,1099,myanmar shan digit nine ០,0,17e0,khmer digit zero ១,1,17e1,khmer digit one ២,2,17e2,khmer digit two ៣,3,17e3,khmer digit three ៤,4,17e4,khmer digit four ៥,5,17e5,khmer digit five ៦,6,17e6,khmer digit six ៧,7,17e7,khmer digit seven ៨,8,17e8,khmer digit eight ៩,9,17e9,khmer digit nine ᠐,0,1810,mongolian digit zero ᠑,1,1811,mongolian digit one ᠒,2,1812,mongolian digit two ᠓,3,1813,mongolian digit three ᠔,4,1814,mongolian digit four ᠕,5,1815,mongolian digit five ᠖,6,1816,mongolian digit six ᠗,7,1817,mongolian digit seven ᠘,8,1818,mongolian digit eight ᠙,9,1819,mongolian digit nine ᥆,0,1946,limbu digit zero ᥇,1,1947,limbu digit one ᥈,2,1948,limbu digit two ᥉,3,1949,limbu digit three ᥊,4,194a,limbu digit four ᥋,5,194b,limbu digit five ᥌,6,194c,limbu digit six ᥍,7,194d,limbu digit seven ᥎,8,194e,limbu digit eight ᥏,9,194f,limbu digit nine ᧐,0,19d0,new tai lue digit zero ᧑,1,19d1,new tai lue digit one ᧒,2,19d2,new tai lue digit two ᧓,3,19d3,new tai lue digit three ᧔,4,19d4,new tai lue digit four ᧕,5,19d5,new tai lue digit five ᧖,6,19d6,new tai lue digit six ᧗,7,19d7,new tai lue digit seven ᧘,8,19d8,new tai lue digit eight ᧙,9,19d9,new tai lue digit nine ᧚,1,19da,new tai lue tham digit one ᪀,0,1a80,tai tham hora digit zero ᪁,1,1a81,tai tham hora digit one ᪂,2,1a82,tai tham hora digit two ᪃,3,1a83,tai tham hora digit three ᪄,4,1a84,tai tham hora digit four ᪅,5,1a85,tai tham hora digit five ᪆,6,1a86,tai tham hora digit six ᪇,7,1a87,tai tham hora digit seven ᪈,8,1a88,tai tham hora digit eight ᪉,9,1a89,tai tham hora digit nine ᪐,0,1a90,tai tham tham digit zero ᪑,1,1a91,tai tham tham digit one ᪒,2,1a92,tai tham tham digit two ᪓,3,1a93,tai tham tham digit three ᪔,4,1a94,tai tham tham digit four ᪕,5,1a95,tai tham tham digit five ᪖,6,1a96,tai tham tham digit six ᪗,7,1a97,tai tham tham digit seven ᪘,8,1a98,tai tham tham digit eight ᪙,9,1a99,tai tham tham digit nine ᭐,0,1b50,balinese digit zero ᭑,1,1b51,balinese digit one ᭒,2,1b52,balinese digit two ᭓,3,1b53,balinese digit three ᭔,4,1b54,balinese digit four ᭕,5,1b55,balinese digit five ᭖,6,1b56,balinese digit six ᭗,7,1b57,balinese digit seven ᭘,8,1b58,balinese digit eight ᭙,9,1b59,balinese digit nine ᮰,0,1bb0,sundanese digit zero ᮱,1,1bb1,sundanese digit one ᮲,2,1bb2,sundanese digit two ᮳,3,1bb3,sundanese digit three ᮴,4,1bb4,sundanese digit four ᮵,5,1bb5,sundanese digit five ᮶,6,1bb6,sundanese digit six ᮷,7,1bb7,sundanese digit seven ᮸,8,1bb8,sundanese digit eight ᮹,9,1bb9,sundanese digit nine ᱀,0,1c40,lepcha digit zero ᱁,1,1c41,lepcha digit one ᱂,2,1c42,lepcha digit two ᱃,3,1c43,lepcha digit three ᱄,4,1c44,lepcha digit four ᱅,5,1c45,lepcha digit five ᱆,6,1c46,lepcha digit six ᱇,7,1c47,lepcha digit seven ᱈,8,1c48,lepcha digit eight ᱉,9,1c49,lepcha digit nine ᱐,0,1c50,ol chiki digit zero ᱑,1,1c51,ol chiki digit one ᱒,2,1c52,ol chiki digit two ᱓,3,1c53,ol chiki digit three ᱔,4,1c54,ol chiki digit four ᱕,5,1c55,ol chiki digit five ᱖,6,1c56,ol chiki digit six ᱗,7,1c57,ol chiki digit seven ᱘,8,1c58,ol chiki digit eight ᱙,9,1c59,ol chiki digit nine ꘠,0,a620,vai digit zero ꘡,1,a621,vai digit one ꘢,2,a622,vai digit two ꘣,3,a623,vai digit three ꘤,4,a624,vai digit four ꘥,5,a625,vai digit five ꘦,6,a626,vai digit six ꘧,7,a627,vai digit seven ꘨,8,a628,vai digit eight ꘩,9,a629,vai digit nine ꣐,0,a8d0,saurashtra digit zero ꣑,1,a8d1,saurashtra digit one ꣒,2,a8d2,saurashtra digit two ꣓,3,a8d3,saurashtra digit three ꣔,4,a8d4,saurashtra digit four ꣕,5,a8d5,saurashtra digit five ꣖,6,a8d6,saurashtra digit six ꣗,7,a8d7,saurashtra digit seven ꣘,8,a8d8,saurashtra digit eight ꣙,9,a8d9,saurashtra digit nine ꤀,0,a900,kayah li digit zero ꤁,1,a901,kayah li digit one ꤂,2,a902,kayah li digit two ꤃,3,a903,kayah li digit three ꤄,4,a904,kayah li digit four ꤅,5,a905,kayah li digit five ꤆,6,a906,kayah li digit six ꤇,7,a907,kayah li digit seven ꤈,8,a908,kayah li digit eight ꤉,9,a909,kayah li digit nine ꧐,0,a9d0,javanese digit zero ꧑,1,a9d1,javanese digit one ꧒,2,a9d2,javanese digit two ꧓,3,a9d3,javanese digit three ꧔,4,a9d4,javanese digit four ꧕,5,a9d5,javanese digit five ꧖,6,a9d6,javanese digit six ꧗,7,a9d7,javanese digit seven ꧘,8,a9d8,javanese digit eight ꧙,9,a9d9,javanese digit nine ꩐,0,aa50,cham digit zero ꩑,1,aa51,cham digit one ꩒,2,aa52,cham digit two ꩓,3,aa53,cham digit three ꩔,4,aa54,cham digit four ꩕,5,aa55,cham digit five ꩖,6,aa56,cham digit six ꩗,7,aa57,cham digit seven ꩘,8,aa58,cham digit eight ꩙,9,aa59,cham digit nine ꯰,0,abf0,meetei mayek digit zero ꯱,1,abf1,meetei mayek digit one ꯲,2,abf2,meetei mayek digit two ꯳,3,abf3,meetei mayek digit three ꯴,4,abf4,meetei mayek digit four ꯵,5,abf5,meetei mayek digit five ꯶,6,abf6,meetei mayek digit six ꯷,7,abf7,meetei mayek digit seven ꯸,8,abf8,meetei mayek digit eight ꯹,9,abf9,meetei mayek digit nine 0,0,ff10,fullwidth digit zero 1,1,ff11,fullwidth digit one 2,2,ff12,fullwidth digit two 3,3,ff13,fullwidth digit three 4,4,ff14,fullwidth digit four 5,5,ff15,fullwidth digit five 6,6,ff16,fullwidth digit six 7,7,ff17,fullwidth digit seven 8,8,ff18,fullwidth digit eight 9,9,ff19,fullwidth digit nine 𐒠,0,104a0,osmanya digit zero 𐒡,1,104a1,osmanya digit one 𐒢,2,104a2,osmanya digit two 𐒣,3,104a3,osmanya digit three 𐒤,4,104a4,osmanya digit four 𐒥,5,104a5,osmanya digit five 𐒦,6,104a6,osmanya digit six 𐒧,7,104a7,osmanya digit seven 𐒨,8,104a8,osmanya digit eight 𐒩,9,104a9,osmanya digit nine 𝟎,0,1d7ce,mathematical bold digit zero 𝟏,1,1d7cf,mathematical bold digit one 𝟐,2,1d7d0,mathematical bold digit two 𝟑,3,1d7d1,mathematical bold digit three 𝟒,4,1d7d2,mathematical bold digit four 𝟓,5,1d7d3,mathematical bold digit five 𝟔,6,1d7d4,mathematical bold digit six 𝟕,7,1d7d5,mathematical bold digit seven 𝟖,8,1d7d6,mathematical bold digit eight 𝟗,9,1d7d7,mathematical bold digit nine 𝟘,0,1d7d8,mathematical double-struck digit zero 𝟙,1,1d7d9,mathematical double-struck digit one 𝟚,2,1d7da,mathematical double-struck digit two 𝟛,3,1d7db,mathematical double-struck digit three 𝟜,4,1d7dc,mathematical double-struck digit four 𝟝,5,1d7dd,mathematical double-struck digit five 𝟞,6,1d7de,mathematical double-struck digit six 𝟟,7,1d7df,mathematical double-struck digit seven 𝟠,8,1d7e0,mathematical double-struck digit eight 𝟡,9,1d7e1,mathematical double-struck digit nine 𝟢,0,1d7e2,mathematical sans-serif digit zero 𝟣,1,1d7e3,mathematical sans-serif digit one 𝟤,2,1d7e4,mathematical sans-serif digit two 𝟥,3,1d7e5,mathematical sans-serif digit three 𝟦,4,1d7e6,mathematical sans-serif digit four 𝟧,5,1d7e7,mathematical sans-serif digit five 𝟨,6,1d7e8,mathematical sans-serif digit six 𝟩,7,1d7e9,mathematical sans-serif digit seven 𝟪,8,1d7ea,mathematical sans-serif digit eight 𝟫,9,1d7eb,mathematical sans-serif digit nine 𝟬,0,1d7ec,mathematical sans-serif bold digit zero 𝟭,1,1d7ed,mathematical sans-serif bold digit one 𝟮,2,1d7ee,mathematical sans-serif bold digit two 𝟯,3,1d7ef,mathematical sans-serif bold digit three 𝟰,4,1d7f0,mathematical sans-serif bold digit four 𝟱,5,1d7f1,mathematical sans-serif bold digit five 𝟲,6,1d7f2,mathematical sans-serif bold digit six 𝟳,7,1d7f3,mathematical sans-serif bold digit seven 𝟴,8,1d7f4,mathematical sans-serif bold digit eight 𝟵,9,1d7f5,mathematical sans-serif bold digit nine 𝟶,0,1d7f6,mathematical monospace digit zero 𝟷,1,1d7f7,mathematical monospace digit one 𝟸,2,1d7f8,mathematical monospace digit two 𝟹,3,1d7f9,mathematical monospace digit three 𝟺,4,1d7fa,mathematical monospace digit four 𝟻,5,1d7fb,mathematical monospace digit five 𝟼,6,1d7fc,mathematical monospace digit six 𝟽,7,1d7fd,mathematical monospace digit seven 𝟾,8,1d7fe,mathematical monospace digit eight 𝟿,9,1d7ff,mathematical monospace digit nine