Discussion:
[BitPim-devel] UNICODE support
Simon C
2005-10-18 06:53:51 UTC
Permalink
UNICODE support requires 4 fixes to be applied to the code

execfile() will not work if the path contains Unicode, the same fix to be
applied in 6 places.
str() will not handle Unicode strings, two fixes, one of them in 3 places
the other in 1 place.
assert() will not work with Unicode paths, fix to be applied in 1 place.

The execfile fix does a chdir before calling execfile with just the
filename.
assert is replaced with os.isfile.
The str fixes involve removing it in one place (not required) and altering
the code logic in the other to only operate on the filename portion of the
path.

I will check these in tomorrow if this is OK with everyone.

Simon
Joe Pham
2005-10-18 10:56:27 UTC
Permalink
Post by Simon C
UNICODE support requires 4 fixes to be applied to the code
Can someome please test out these changes on both the Mac & Linux & post the results before the next build?

-Joe Pham




______________________________________________________________________
Revolutionize the way you surf the Web!
Try NetZero HiSpeed 3G.
Visit http://www.netzero.com to sign up today!
Simon C
2005-10-19 02:34:03 UTC
Permalink
Post by Joe Pham
Post by Simon C
UNICODE support requires 4 fixes to be applied to the code
Can someome please test out these changes on both the Mac & Linux & post
the results before the next build?
Changes checked in. 2 of the 4 affect non-windows versions.
1 change is tested by loading bitpim the other is to add a ringer and
wallpaper using the add button, if this works all the changes have been
exercised.

Simon
Joe Pham
2005-10-20 02:07:23 UTC
Permalink
1. FileView.decodefilename does nothing.
2. Need to account for potential use of this codec outside of FileView objects.

-Joe Pham


______________________________________________________________________
Revolutionize the way you surf the Web!
Try NetZero HiSpeed 3G.
Visit http://www.netzero.com to sign up today!
Simon C
2005-10-20 02:46:58 UTC
Permalink
Post by Joe Pham
1. FileView.decodefilename does nothing.
def decodefilename(self, filename):
path,filename=os.path.split(filename)
decoded_file=str(filename).decode(media_codec)
return os.path.join(path, filename)

It prevents the decode function from operating on the path of the filename
because if the path contains Unicode characters it causes str() to throw a
unicode exception.
It also fixes a problem where the path contains characters not supported by
the phone. To see what I mean, create a directory with a single quote ' in
its name and put a wallpaper file in it, go to the wallpaper tab and use the
add button or drag and drop to add this picture in this directory. Same
thing happens with ringers.
Post by Joe Pham
2. Need to account for potential use of this codec outside of FileView
objects.
I agree.
I wonder if we should stop using the decode function as it does not work
with Unicode strings, if you pass the filename directly to the decode
function without using str() it gives an exception.
Joe Pham
2005-10-20 03:25:51 UTC
Permalink
def decodefilename(self, filename):
path,filename=os.path.split(filename)
decoded_file=str(filename).decode(media_codec)
return os.path.join(path, filename)

It returnes the same thing that was passed in, therefore it does nothing.


-Joe Pham




______________________________________________________________________
Revolutionize the way you surf the Web!
Try NetZero HiSpeed 3G.
Visit http://www.netzero.com to sign up today!
Simon C
2005-10-20 03:34:18 UTC
Permalink
Post by Simon C
path,filename=os.path.split(filename)
decoded_file=str(filename).decode(media_codec)
return os.path.join(path, filename)
It returnes the same thing that was passed in, therefore it does nothing.
Typo on my part, the last line is wrong, I'll fix it.

Simon

Loading...