> > >> Ok,so you confirm that: >> >> s = u"ciao è ciao" will use the file specified encoding, and that >> >> t = "ciao è ciao" >> t = unicode(t) >> >> Will use, if not specified in the function, ASCII. It will ignore the >> encoding I specified on the top of the file. right? >> >> >> > A literal "u" string, and only such a (unicode) literal string, is > affected by the encoding specification. Once some bytes have been stored in > a 8 bit string, the system does *not* keep track of where they came from, > and any conversions then (even if they're on an adjacent line) will use the > default decoder. This is a logical example of what somebody said earlier on > the thread -- decode any data to unicode as early as possible, and deal only > with unicode strings in the program. Then, if necessary, encode them into > whatever output form immediately before (or while) outputting them. > > > Ok Dave, What i don't understand is why:
s = u"ciao è ciao" is converting a string to unicode, decoding it from the specified encoding but t = "ciao è ciao" t = unicode(t) That should do exactly the same instead of using the specified encoding always assume that if i'm not telling the function what the encoding is, i'm using ASCII. Is this a bug? Giorgio -- -- AnotherNetFellow Email: anothernetfel...@gmail.com
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor