By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,345 Members | 1,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,345 IT Pros & Developers. It's quick & easy.

drag drop from linux to a wxpython application

P: n/a
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)
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
marco wrote:
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:
import urllib
urllib.unquote ("/home/marc/my%20photos")

'/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
Jul 18 '05 #2

P: n/a
marco <ma******@online.fr> wrote in message news:<40***********************@news.free.fr>...
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
Jul 18 '05 #3

P: n/a
simo a écrit :
marco <ma******@online.fr> wrote in message news:<40***********************@news.free.fr>...
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


thanks a lot ...
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.