Login

UTF-8 Katakana

Author:
hdknr
Posted:
April 17, 2010
Language:
Python
Version:
1.1
Tags:
utf8 katakana
Score:
1 (after 1 ratings)

Katakana in UTF-8 check

1
2
3
        def is_katakana(src):
            r = re.search(r'^(\xe3(\x82[\xa1-\xbf]|\x83[\x80-\xb6]|\x83[\xbb-\xbe]))+$',src.encode('utf8'))
            return ( r != None )

More like this

Comments

shoma (on April 19, 2010):
<p>my code is:</p> <pre>import unicodedata def is_katakana(unichr): unichr = unicodedata.normalize('NFC', unichr) for c in unichr: if not unicodedata.name(c).startswith('KATAKANA'): return False return True </pre>

#

Please login first before commenting.