String is ASCII or UTF-8?

Terry Reedy tjreedy at udel.edu
Tue Mar 9 12:59:16 EST 2010


On 3/9/2010 11:54 AM, C. Benson Manica wrote:
> Hours of Googling has not helped me resolve a seemingly simple
> question - Given a string s, how can I tell whether it's ascii (and
> thus 1 byte per character) or UTF-8 (and two bytes per character)?

Utf-8 is an encoding that uses 1 to 4 bytes per character.
So it is not clear what you are asking. Alf answered one of the possible 
questions.

> This is python 2.4.3, so I don't have getsizeof available to me.





More information about the Python-list mailing list