![](https://secure.gravatar.com/avatar/01aa7d6d4db83982a2f6dd363d0ee0f3.jpg?s=120&d=mm&r=g)
"MvL" == Martin v Löwis <loewis@informatik.hu-berlin.de> writes:
>> 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