On 06/04/2013 08:18 AM, Νικόλαος Κούρας wrote:
> No, brackets are all there. Just tried:
> 
> # Compute a set of current fullpaths
> fullpaths = set()
> path = "/home/nikos/www/data/apps/"
> 
> for root, dirs, files in os.walk(path):
>       for fullpath in files:
>               fullpaths.add( os.path.join(root, fullpath) )
>               print (fullpath )
>               print (fullpath.encode('iso-8859-7').decode('latin-1') )

                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This is wrong.  You are converting unicode to iso-8859-7 bytes, then
trying to convert those bytes back to unicode by pretending they are
latin-1 bytes.  Even if this worked it will generate garbage.

> What are these 'surrogate' things?

It means that when you tried to decode greek bytes using latin-1, there
were some invalid unicode letters created (which is expected, since the
bytes are not latin-1, they are iso-8859-7!).

If you want the browser to use a particular encoding scheme (utf-8),
then you have to print out an HTTP header before you start printing your
other HTML data:

print("Content-Type: text/html;charset=UTF-8\r\n")
print("\r\n)

print("html data goes here)


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to