[Mailman-i18n] "Funny" characters in real names?
Barry A. Warsaw
barry@python.org
Thu, 19 Sep 2002 00:07:40 -0400
>>>>> "MvL" =3D=3D Martin v L=F6wis <loewis@informatik.hu-berlin.de> wr=
ites:
>> BG> Again, I assume you mean ISO-8859-1 instead of ascii here.
>> Same thing here. We do name.encode('us-ascii') and catch any
>> UnicodeError that might occur.
MvL> That should be name.decode, or unicode(name,
MvL> "us-ascii"). name.encode unfortunately works as well, but it
MvL> first decodes using the system default encoding, then encodes
MvL> using us-ascii - very close to what you want, but not the
MvL> precise same thing.
Martin, sometimes this Unicode stuff makes my head hurt. ;)
I don't think I can use name.decode() because that's a Python 2.2-ism
and we need to stick to Python 2.1.
I don't think I can use unicode(name, 'us-ascii') because what if name
is already a Unicode string? This'll give me a TypeError.
So it seems like name.encode('us-ascii') is my only choice. What am I
missing?
-Barry