How to store ASCII encoded python string?
micahc at gmail.com
micahc at gmail.com
Mon Aug 28 16:51:58 EDT 2006
Fredrik Lundh wrote:
> 3) convert the data to Unicode before passing it to the database
> interface, and leave it to the interface to convert it to whatever
> encoding your database uses:
>
> data = ... get encoded string from email ...
> text = data.decode("iso-8859-1")
> ... write text to database ...
Wouldn't that have to assume that all incoming data is in iso-8859-1?
If someone sends me an email with chinese characters would that still
work (I don't know the character set at data insert time)?
Marc 'BlackJack' Rintsch wrote:
> In [6]: '\tsome text\xa7some more text\n'.encode('string_escape')
> Out[6]: '\\tsome text\\xa7some more text\\n'
Thanks, I think this is what I will end up doing just for simplicity,
though I'm still curious about the above question.
More information about the Python-list
mailing list