drag drop from linux to a wxpython application

M

marco

I've got a wxpython application
and when i drag'n' drop files from(linux) rox/nautilus/konqueror to my app
i've got strange chars in filenames (on win32 : it works well)

example:
- my dir "my photos" will become "/home/marc/my%20photos"
- a dir "fêtes à strass" will become (something like this)
"/home/marc/f%A8%CFtes%20%8F%AC%20strass"

it seems the filenames are "escaped" ... is there a way to got the good
filenames ? (i means it doesn't come from python, but perhaps it's an
encoding problems ?! i'd like to use a function like "unescape()" in
javascript, to clean them)
 
D

Daniel Dittmar

marco said:
I've got a wxpython application
and when i drag'n' drop files from(linux) rox/nautilus/konqueror to
my app i've got strange chars in filenames (on win32 : it works well)

example:
- my dir "my photos" will become "/home/marc/my%20photos"
- a dir "fêtes à strass" will become (something like this)
"/home/marc/f%A8%CFtes%20%8F%AC%20strass"

use urllib.unquote:'/home/marc/my photos'

I guess that the result is a utf8 string which has to be translated to ASCII
Latin1 or UCS[24] to become a regular Python string. At least that would
explain why ê and à occupy two characters in the encoded form.

Daniel
 
S

simo

marco said:
I've got a wxpython application
and when i drag'n' drop files from(linux) rox/nautilus/konqueror to my app
i've got strange chars in filenames (on win32 : it works well)

example:
- my dir "my photos" will become "/home/marc/my%20photos"
- a dir "fêtes à strass" will become (something like this)
"/home/marc/f%A8%CFtes%20%8F%AC%20strass"

This is URL encoding. Basically because the use of top-bit-set
characters and spaces in filenames is evil. Don't forget that most
file managers are basically web browsers....

You'd need to URL decode the chars to get your original filename as on
Windows, try:

import urllib
print urllib.unquote_plus("f%A8%CFtes%20%8F%AC%20strass")

That will fix your %xx characters, although I don't get the same
encoding as you're getting there (maybe it's a unicode thing?):

print urllib.quote("fêtes à strass")
f%EAtes%20%E0%20strass
 
M

marco

simo a écrit :
This is URL encoding. Basically because the use of top-bit-set
characters and spaces in filenames is evil. Don't forget that most
file managers are basically web browsers....

You'd need to URL decode the chars to get your original filename as on
Windows, try:

import urllib
print urllib.unquote_plus("f%A8%CFtes%20%8F%AC%20strass")

That will fix your %xx characters, although I don't get the same
encoding as you're getting there (maybe it's a unicode thing?):

print urllib.quote("fêtes à strass")
f%EAtes%20%E0%20strass

thanks a lot ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top