Turnign greek-iso filenames => utf-8 iso
Νικόλαος Κούρας
support at superhost.gr
Wed Jun 12 05:00:38 EDT 2013
On 12/6/2013 11:31 πμ, Steven D'Aprano wrote:
> On Wed, 12 Jun 2013 08:02:24 +0000, Νικόλαος Κούρας wrote:
>
>> i tried to insert
>> print( filename )
>> sys.exit(0)
>
> That's not very useful. That will just print ONE file name, then stop.
> You have how many files in there? Two? Twenty? What if the problem does
> not lie with the first one?
>
>> just before the execute
>> and the output is just Pacman.exe as seen in
>>
>> http://superhost.gr/?page=files.py
>
> Wrong. The output is:
>
> Internal Server Error
print( filenames )
sys.exit(0)
No it dosnt not, it loads properly and if you visit it again you will
see all the files being displayed since now i:
print( filenames )
sys.exit(0)
Thne grek ones ar displayed as
'\udcce\udc95\udccf\udc85\udccf\udc87\udcce\udcae
\udccf\udc84\udcce\udcbf\udccf\udc85
\udcce\udc99\udcce\udcb7\udccf\udc83\udcce\udcbf\udccf\udc8d.mp3' in Chrome
dont know why since the above procedure supposed to turned them into utf-8
ls -l apps though via putty display all filesnames correctly.
===============
# Collect filenames of the path dir as strings
filenames = os.listdir( '/home/nikos/public_html/data/apps/' )
# Build a set of 'path/to/filename' based on the objects of path dir
filepaths = set()
for filename in filenames:
filepaths.add( filename )
# Load'em
for filename in filenames:
try:
# Check the presence of a file against the database and insert if it
doesn't exist
print( filenames )
sys.exit(0)
cur.execute('''SELECT url FROM files WHERE url = %s''', filename )
data = cur.fetchone()
===============================
Into the database only 2 english have been inserted pacman.exe and one
other english filenames before filename breaks into the execute statemnt.
More information about the Python-list
mailing list