create a string of variable lenght

Tracubik affdfsdfdsfsd at b.com
Sun Jan 31 17:12:38 EST 2010


Il Sun, 31 Jan 2010 13:46:16 +0100, Günther Dietrich ha
scritto:

> Maybe you might solve this if you decode your string to unicode.
> Example:
> 
> |>>> euro = "€"
> |>>> len(euro)
> |3
> |>>> u_euro = euro.decode('utf_8')
> |>>> len(u_euro)
> |1
> 
> Adapt the encoding ('utf_8' in my example) to whatever you use.
> 
> Or create the unicode string directly:
> 
> |>>> u_euro = u'€'
> |>>> len(u_euro)
> |1
> 
> 
> 
> Best regards,
> 
> Günther

thank you, your two solution is really interesting.
is there a possible to set unicode encoding by default for my python 
scripts?
i've tried inserting 
# -*- coding: utf-8 -*-

at the beginning of my script but doesn't solve the problem



More information about the Python-list mailing list