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. find even number by Rajeev529 2 weeks, 2 days ago
  2. Form field with fixed value by roam 1 month, 1 week ago
  3. New Snippet! by Antoliny0919 1 month, 2 weeks ago
  4. Add Toggle Switch Widget to Django Forms by OgliariNatan 4 months ago
  5. get_object_or_none by azwdevops 7 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.