[Pythonmac-SIG] Carbon.CoreFoundation - null-terminated unicode
strings??
Bob Ippolito
bob at redivi.com
Fri Mar 12 14:02:46 EST 2004
On Mar 12, 2004, at 4:02 PM, has wrote:
> Hi,
>
> Noticed the following strange behaviour; not entirely sure which
> code's responsible for it and can't help feeling it's some sort of
> bug, but maybe someone can shed some light on it?
>
> #######
>
> #!/usr/local/bin/pythonw
>
> import Carbon.CoreFoundation as CF
> from appscript import LaunchServices
>
> path = 'TextEdit.app'
>
> fURL = LaunchServices.LSFindApplicationForInfo ('????', None, path)[1]
>
> print [c for c in
> (fURL.CFURLCopyFileSystemPath(CF.kCFURLPOSIXPathStyle).CFStringGetUnico
> de())]
>
> --> [u'/', u'A', u'p', u'p', u'l', u'i', u'c', u'a', u't', u'i', u'o',
> u'n', u's', u'/', u'T', u'e', u'x', u't', u'E', u'd', u'i', u't',
> u'.', u'a', u'p', u'p', u'\x00'] -- why is last character 0x00???
You should be using the toPython method to bridge any Carbon.CF
instance:
>>> import LaunchServices.Launch
>>> import Carbon.CoreFoundation as CFConst
>>> LaunchServices.Launch.LSFindApplicationForInfo('????', None,
u'iTunes.app')[1].CFURLCopyFileSystemPath(CFConst.kCFURLPOSIXPathStyle).
toPython()
u'/Applications/iTunes.app'
-bob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2357 bytes
Desc: not available
Url : http://mail.python.org/pipermail/pythonmac-sig/attachments/20040312/f9ca38df/smime.bin
More information about the Pythonmac-SIG
mailing list