Liam Clarke wrote: > So, using > > val = unicode(value) > self._slaveMap[attr].setPayload(value.encode("UTF-16")) > > I can stick normal strings in happily. Of course, as you mentioned, > Kent, this leaves me vulnerable if the string differs to > sys.getdefaultencoding(). > > Other than directly from the user, the most likely source of data will > be from pyid3lib, which for the time being assumes all strings are > ISO-8859-1.
You can decode with iso-8859-1 instead of ascii: val = unicode(value, 'iso-8859-1') self._slaveMap[attr].setPayload(value.encode("UTF-16")) you could even allow client code to tell you the encoding: def setPayload(self, val, encoding='iso-8859-1'): if not isinstance(value, unicode): value = unicode(value, encoding) self._slaveMap[attr].setPayload(value.encode("UTF-16")) Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor