[Pythonmac-SIG] ascii <-> unicode <-> cocoa NSString
Bob Ippolito
bob at redivi.com
Mon Feb 20 22:16:59 CET 2006
On Feb 20, 2006, at 1:05 PM, Keith Ray wrote:
> PyFIT gives me ascii strings,and I am trying to call cocoa (and
> eventually some applescript) functions from Python. I tried
>
> from Foundation import NSString
> from AppKit import NSWorkspace
> import os.path
>
> ....etc...
>
> ws = NSWorkspace.sharedWorkspace()
> uapplicationpath = unicode(self.applicationpath, 'ascii')
> self.launchsuccess = ws.launchApplication_(
> NSString.stringWithString_(uapplicationpath) )
>
> but get a traceback:
>
> line 23, in result
> uapplicationpath = unicode(self.applicationpath, 'ascii')
> TypeError: decoding Unicode is not supported
unicode(someUnicodeString, someEncoding) is always an error. You
must already have a unicode string for self.applicationpath.
$ python
Python 2.4.2 (#2, Feb 4 2006, 22:23:07)
[GCC 4.0.0 (Apple Computer, Inc. build 5026)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> unicode(u'incorrect code', 'ascii')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: decoding Unicode is not supported
-bob
More information about the Pythonmac-SIG
mailing list