How to find number of characters in a unicode string?

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Fri Sep 29 04:11:34 EDT 2006


In <efija1$357$1 at lust.ihug.co.nz>, Lawrence D'Oliveiro wrote:

> In message <pan.2006.09.18.20.29.20.510034 at gmx.net>, Marc 'BlackJack'
> Rintsch wrote:
> 
>> In <20060918221814.08625ea2.randhol+valid_for_reply_from_news at pvv.org>,
>> Preben Randhol wrote:
>> 
>>> Is there a way to calculate in characters
>>> and not in bytes to represent the characters.
>> 
>> Decode the byte string and use `len()` on the unicode string.
> 
> Hmmm, for some reason
> 
>     len(u"C\u0327")
> 
> returns 2.

Okay, decode and normalize and then use `len()` on the unicode string.

Ciao,
	Marc 'BlackJack' Rintsch




More information about the Python-list mailing list