Indicate if the character is a combined diacritic mark

if you loop unicode character characters in python (2.x), say:

ak.sɛp.tɑ

How can you determine if the current char is a combination of a diacritical mark?

For example, the last char in the above line is actually a combination label:

ak.sɛp.tɑ →

+3
source share
1 answer

Use the unicodedata module:

import unicodedata
if unicodedata.combining(u'a'):
    print "is combining character"
else:
    print "is not combining"

these messages are also relevant

How to undo Unicode decomposition using Python?

What is the best way to remove accents in a Python Unicode string?

+8
source

Source: https://habr.com/ru/post/1704600/


All Articles