Re: [Pyobjc-dev] Re: [ pyobjc-Bugs-679748 ] NSMutableString gets converted to Python string
Brought to you by:
ronaldoussoren
From: Bob I. <bo...@re...> - 2003-02-03 23:19:37
|
On Monday, Feb 3, 2003, at 18:08 America/New_York, David Eppstein wrote: > 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. unicode(s) works for any str or unicode instance, or any instance that otherwise implements __str__ and/or __unicode__. If it's a str or __str__ that has 8-bit characters, you have to specify an encoding. Optionally you may also specify a way to handle errors ('strict', 'ignore', or 'replace'). -bob |