[Pythonmac-SIG] Python Unicode and NSString...
Nicholas Riley
njriley at uiuc.edu
Tue May 30 10:07:07 CEST 2006
On Tue, May 30, 2006 at 09:33:32AM +0200, whamoo wrote:
> Hi all!
>
> i'm at war with unicode python and cocoa, and seem that i cannot
> win... =)
>
> i've wrote this function:
>
> def makeNSString(self, oldString):
> try:
> oldString = NSString.stringWithUTF8String_(oldString)
> return oldString
> except Exception, e:
> print Exception, e
> return oldString
>
> And it work, now in my app i have all the ?,?,?,? correctly written,
> but it raise this exception each time:
>
> exceptions.Exception depythonifying 'charptr', got 'unicode'
>
> This is normal? what can i do? ;)
What are you trying to do? If the string is already Unicode, PyObjC
will make it into a NSString for you. If you want to encode a Unicode
string as UTF-8, then use oldString.encode('utf-8').
--
Nicholas Riley <njriley at uiuc.edu> | <http://www.uiuc.edu/ph/www/njriley>
More information about the Pythonmac-SIG
mailing list