Edward Loper wrote:
> I would like to convert an 8-bit string (i.e., a str) into unicode,
> treating chars \x00-\x7f as ascii, and converting any chars \x80-xff
> into a backslashed escape sequences.  I.e., I want something like this:
> 
>  >>> decode_with_backslashreplace('abc \xff\xe8 def')
> u'abc \\xff\\xe8 def'

  >>> s='abc \xff\xe8 def'
  >>> s.encode('string_escape')
'abc \\xff\\xe8 def'
  >>> unicode(s.encode('string_escape'))
u'abc \\xff\\xe8 def'

Kent
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to