hex dump w/ or w/out utf-8 chars

MRAB python at mrabarnett.plus.com
Mon Jul 8 19:32:00 EDT 2013


On 08/07/2013 23:02, Joshua Landau wrote:
> On 8 July 2013 22:38, MRAB <python at mrabarnett.plus.com> wrote:
>> On 08/07/2013 21:56, Dave Angel wrote:
>>> Characters do not have a width.
>>
>> [snip]
>>
>> It depends what you mean by "width"! :-)
>>
>> Try this (Python 3):
>>
>>>>> print("A\N{FULLWIDTH LATIN CAPITAL LETTER A}")
>> AA
>
> Serious question: How would one find the width of a character by that
> definition?
>
 >>> import unicodedata
 >>> unicodedata.east_asian_width("A")
'Na'
 >>> unicodedata.east_asian_width("\N{FULLWIDTH LATIN CAPITAL LETTER A}")
'F'

The possible widths are:

     N  = Neutral
     A  = Ambiguous
     H  = Halfwidth
     W  = Wide
     F  = Fullwidth
     Na = Narrow

All you then need to do is find out what those actually mean...




More information about the Python-list mailing list