Checking a character is fullwidth or halfwidth in Python -
i want check whether character fullwidth or halfwidth using python
string="你好hallo" char in string: if( \uff60- \u0f01 , \uffe0-\uffe6 ): print( char +"is fullwidth") elif(\uff61-\uffdc , \uffe8-\uffee):print(char+ " halfwidth")
please me change pseudocode real python code.
you can check width of character using unicodedata.east_asian_width(unichr)
:
import unicodedata char in string: status = unicodedata.east_asian_width(char) if status == 'f': print('{0} full-width.'.format(char)) elif status == 'h': print('{0} half-width.'.format(char))
Comments
Post a Comment