Please let me post the third update O_o. You can forgot other 2, i'll put them into this email.<div><br></div><div>---</div><div><div>>>> s = "ciao è ciao"</div><div>>>> print s</div><div>ciao è ciao</div>
<div>>>> s.encode('utf-8')</div><div><br></div><div>Traceback (most recent call last):</div><div> File "<pyshell#2>", line 1, in <module></div><div> s.encode('utf-8')</div>
<div>UnicodeDecodeError: 'ascii' codec can't decode byte 0xe8 in position 5: ordinal not in range(128)</div><div>---</div><div><br></div><div>I am getting more and more confused.</div><div><br></div><div>I was coding in PHP and was saving some strings in the DB. Was using utf8_encode to encode them before sending to the utf8_unicode_ci table. Ok, the result was that strings were "double encoded". To fix that I simply removed the utf8_encode() function and put the "raw" data in the database (that converts them in utf8). In other words, in PHP, I can encode a string multiple times:</div>
<div><br></div><div>$c = "giorgio è giorgio";</div><div>$c = utf8_encode($c); // this will work in an utf8 html page</div><div>$d = utf8_encode($c); // this won't work, will print a strange letter</div><div>
$d = utf8_decode($d); // this will work. will print an utf8 string</div><div><br></div><div>Ok, now, the point is: you (and the manual) said that this line:</div><div><br></div><div>s = u"giorgio è giorgio"</div>
<div><br></div><div>will convert the string as unicode. But also said that the part between "" will be encoded with my editor BEFORE getting encoded in unicode by python. So please pay attention to this example:</div>
<div><br></div><div>My editor is working in UTF8. I create this:</div><div><br></div><div>c = "giorgio è giorgio" // This will be an UTF8 string because of the file's encoding</div><div>d = unicode(c) // This will be an unicode string</div>
<div>e = c.encode() // How will be encoded this string? If PY is working like PHP this will be an utf8 string.</div><div><br></div><div>Can you help me?</div><div><br></div><div>Thankyou VERY much</div><div><br></div><div>
Giorgio</div>
</div>