UnicodeEncodeError in add_action_print with non ascii files names

John A Meinel john at arbash-meinel.com
Sun Feb 5 12:50:40 GMT 2006


Nir Soffer wrote:
> 
> On 5 Feb, 2006, at 6:50, John A Meinel wrote:
> 
>> It isn't that Mac doesn't support unicode filenames, but that it
>> normalizes them.
> 
> It decompose them into multiple characters 'a with a circle' -> 'a' +
> 'circle', as explained here
> <http://developer.apple.com/documentation/MacOSX/Conceptual/BPInternational/Articles/FileEncodings.html>
> 
> 
> Note that according to the doc above, any system routine should be
> called with the decomposed form, but both forms work with Python
> os.path.exists.
> 
...

> Using PyObjC, this function precompose back to the common form:
> 
>>>> def normalize(name):
> ...     return
> NSString.stringWithString_(name).precomposedStringWithCanonicalMapping()
> 
>>>> normalize(u'a\u030a')
> u'\xe5'
> 

It is actually easier to use

>>> import unicodedata
>>> unicodedata.normalize('NFKC', s)
>>> unicodedata.normalize('NFKD', s)

Then it isn't dependent specifically on Mac OS X.

But thanks for the pointers.

> There is also - (NSString *)precomposedStringWithCompatibilityMapping,
> which give the same results with this test string. The first use Unicode
> Normalization Form C, the second Unicode Normalization Form KC (I don't
> have any idea what is difference :-) )
> 
> <http://developer.apple.com/documentation/Cocoa/Reference/Foundation/ObjC_classic/Classes/NSString.html#//apple_ref/occ/instm/NSString/precomposedStringWithCanonicalMapping>
> 
> 
> I guess the same call is available through Carbon/CoreFoundation.
> 
> I'll be happy to help with the Unicode support. I have some free time
> later this month.
> 

When you get free time, let me know. I think I have things sorted out as
to what needs to happen. I just haven't had the time to actually do it.

>> By the way, it is nice to have some hebrew characters. Do you have a
>> specific meaning for 'שלום'? I've been collecting non-english words, and
>> I prefer to have a translation with them.
> 
> שלום (sha-lom) is both hello and peace :-)

I've certainly heard the word. I've just never seen it in Hebrew.

John
=:->

> 
> Maybe you will like Limon, which is a Free (GPL) Hebrew English online
> dictionary for Mac OS X, written using PyObjC. You can writh English
> words and get the Hebrew translation.
> http://nirs.freeshell.org/limon/
> 
> 
> Best Regards,
> 
> Nir Soffer
> 
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060205/1f6f44bf/attachment.pgp 


More information about the bazaar mailing list