Re: [Pyobjc-dev] Re: [ pyobjc-Bugs-679748 ] NSMutableString gets converted to Python string
Brought to you by:
ronaldoussoren
From: David E. <epp...@ic...> - 2003-02-03 23:08:47
|
On 2/3/03 10:48 PM +0100 Just van Rossum <ju...@le...> wrote: > What works nicely now is that the conversion of unicode strings to > NSStrings and vice versa is really transparant: pass Python unicode > strings to ObjC call expecting an NSString and it works. The other way > also: if the NSString is representable in 7-bit ascii you get a str, if > not you get a unicode string. My code certainly depends on this (at least, the part about sending unicode strings to objc and getting unicode strings back). > I worry about that Python users will have > to convert to a unicode string after all when this conversion _doesn't_ > take place. Currently, because of the 7-bit possibility, if you want a unicode string from a value s that came from the objc side, you need to call unicode(s). I hope and assume that whatever happens with strings, unicode(s) will still work. > Python has only limited support for unicode file names and I believe > it's highly platform dependent. Right now it doesn't work with unicode > strings on OSX, but it does work with 8-bit strings encoded as utf-8: > >>>> os.stat('a\xcc\x8a') > (33188, 1685956L, 234881029L, 1, 501, 20, 0L, 1044307510, 1044307510, > 1044307510) >>>> os.stat(unicode('a\xcc\x8a', "utf-8")) > Traceback (most recent call last): > File "<stdin>", line 1, in ? > UnicodeEncodeError: 'ascii' codec can't encode character '\u30a' in > position 1: ordinal not in range(128) >>>> > > This seems pretty broken, but I don't know enough of the internals to > see what it would take to fix this. There seems to be a thread going now on c.l.py about unicode filenames... -- David Eppstein UC Irvine Dept. of Information & Computer Science epp...@ic... http://www.ics.uci.edu/~eppstein/ |