Login

UTF-8 Katakana

Author:
hdknr
Posted:
April 17, 2010
Language:
Python
Version:
1.1
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

  1. Form field with fixed value by roam 1 week, 4 days ago
  2. New Snippet! by Antoliny0919 2 weeks, 3 days ago
  3. Add Toggle Switch Widget to Django Forms by OgliariNatan 3 months, 1 week ago
  4. get_object_or_none by azwdevops 6 months, 4 weeks ago
  5. Mask sensitive data from logger by agusmakmun 8 months, 3 weeks ago

Comments

shoma (on April 19, 2010):

my code is:

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

#

Please login first before commenting.