jdonnell wrote:
I have a mysql database with characters like � � » in it. I'm
trying to write a python script to remove these, but I'm having a
really hard time.
use the "hammer" recipe. i'm using it to create URL-friendly
fragment from latin-1 album titles:
<http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/251871>
(check the last comment, "a cleaner solution"
for a better implementation).
it basically hammers down accented chars like � and �
to the most near ASCII representation.
since you receive string data as str from mysql
object first convert them as unicode with:
u = unicode('�', 'latin-1')
then feed u to the hammer function (the fix_unicode at the
end).
HTH,
deelan
--
"Per� � bello sapere che, di questi tempi spietati, almeno
un mistero sopravvive: l'et� di Afef Jnifen." -- dagospia.com
--
http://mail.python.org/mailman/listinfo/python-list