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. Template tag - list punctuation for a list of items by shapiromatron 2 months, 2 weeks ago
  2. JSONRequestMiddleware adds a .json() method to your HttpRequests by cdcarter 2 months, 3 weeks ago
  3. Serializer factory with Django Rest Framework by julio 9 months, 2 weeks ago
  4. Image compression before saving the new model / work with JPG, PNG by Schleidens 10 months, 1 week ago
  5. Help text hyperlinks by sa2812 11 months 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.