Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Path and Unicode woes

Thread Tools

Path and Unicode woes

Posts: n/a
I'm attempting to override a wxHtmlWindow method in order to
pre-process the file before displaying it. I'm using a unicode version
of wxPython. I don't think my problem are wxPython-specific, but
rather a unicode mis-understanding. Consider the following:

.. def OnLinkClicked(self, linkinfo):
.. #adapted from the wxPython demo
.. target_file = linkinfo.GetHref()
.. current = self.GetOpenedPage()
.. path = os.path.dirname(current)
.. print "path = ", path
.. print "current = ", current
.. print "target_file = ", target_file
.. filename = os.path.join(path, target_file)
.. print "filename = ", filename
.. filename = filename.replace('\\','/')
.. print "filename: ", filename+'\n'
.. self.LoadFile(filename)

The first time I *click* on a link, I get the following:

path = E:/Copy of rurple0.9.0.1b/rurple0.9.0.1/html/en
current = E:/Copy of rurple0.9.0.1b/rurple0.9.0.1/html/en/rur.htm.html
target_file = intro/browser.htm
filename = E:/Copy of
filename: E:/Copy of

.... and everything is just fine (the expected file opens in the browser
window). The second time I *click* on a link, I get the following
(note the replacement of "E:" by "/E%3A"):

path = /E%3A/Copy of rurple0.9.0.1b/rurple0.9.0.1/html/en/intro
current = /E%3A/Copy of
target_file = explore.htm
filename = /E%3A/Copy of
filename: /E%3A/Copy of

Traceback (most recent call last):
File "E:\Copy of rurple0.9.0.1b\rurple0.9.0.1\rur_py\",
line 77, in OnLinkClicked
File "E:\Copy of rurple0.9.0.1b\rurple0.9.0.1\rur_py\",
line 54, in LoadFile
data = open(filename, 'r').read()
IOError: [Errno 2] No such file or directory: u'/E%3A/Copy of

Any help or pointers would be appreciated...


Reply With Quote
Posts: n/a
Not full help - but still a pointer.

E%3A/ isn't a unicode issue - but a value that is HTML escaped. MEaning
(I presume without looking it up) 'E:/' - your file path.

All the best,


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Python unicode utf-8 characters and MySQL unicode utf-8 characters Grzegorz Śliwiński Python 2 01-19-2011 07:31 AM
Help for Unicode char and Unicode char based string in Ruby Chirag Mistry Ruby 6 02-08-2008 12:45 PM
sys.path and unicode folder names Nir Aides Python 11 02-09-2006 07:42 PM
Execution and dos path woes Karl von Laudermann Ruby 2 10-28-2004 07:12 PM
Re: Eclipse tag library path woes Chris Smith Java 0 07-07-2003 12:26 AM