Ciao Samuele On Sun, Jun 15, 2008 at 23:40, Zanon Samuele <[EMAIL PROTECTED]> wrote: > Scusate... mi è partito il messaggio senza allegato... eccolo... > 2008/6/15 Zanon Samuele <[EMAIL PROTECTED]>: >> -MySQL >> -utf-8 >> -in teoria si >> -In allegato trovato lo script.... >> Come toverete nello script, che le stringhe di testo estratte dal database >> ho provato a fare un encode in utf-8 tramite il metodo .encode delle >> stringhe. >> provate a vedere se c'è un errore o qualcosa per poter sistemare la >> cosa... grazie mille
Uhm, evidentemente alcuni (o tutti) i dati nel tuo DB non sono UTF8. Potresti provare con altre codifiche. Oppure, se i dati "sporchi" sono pochi, potresti usare il secondo parametro di encode, magari con il valore "xmlcharrefreplace": >>> help(unicode.encode) Help on method_descriptor: encode(...) S.encode([encoding[,errors]]) -> string or unicode Encodes S using the codec registered for encoding. encoding defaults to the default encoding. errors may be given to set a different error handling scheme. Default is 'strict' meaning that encoding errors raise a UnicodeEncodeError. Other possible values are 'ignore', 'replace' and 'xmlcharrefreplace' as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors. Ti consiglio di leggerti i diversi ottimi tutorial su unicode in python. Uno lo trovi anche sul sito di Reportlab: <http://www.reportlab.com/i18n/python_unicode_tutorial.html> Happy hacking, (c) -- Carlo C8E Miron Fscking Unicode Solution Architect™ <http://www.linkedin.com/in/carlomiron> <http://pycon.it/> <http://stacktrace.it/> <http://pydinner.org/> _______________________________________________ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python