working with unicode in python

   5848   5   2
User Avatar
Member
23 posts
Joined: Nov. 2011
Offline
Hello,

doing something like:


s = u“a unicode sting”
print s


results in an TypeError in recent 11.1.64. So, no unicode strings in houdini? This is especially annoying when using PyQt QString api v2…

Cheers

Sebastian
User Avatar
Member
300 posts
Joined: Jan. 2010
Offline
You could just define a function that encodes it before printing.

def printU(s):
print s.encode('utf-8')

EDIT: If it's the actual print that breaks.
Drive, monkey, drive!
User Avatar
Member
23 posts
Joined: Nov. 2011
Offline
Thats what I am doing, but isnt it a little bit strange not being able to print unicode (is it the same on linux?!)
User Avatar
Member
300 posts
Joined: Jan. 2010
Offline
It depends on what console you are using. Anyways its not really a Houdini problem. Search for it on stackoverflow and there are loads of threads.
Drive, monkey, drive!
User Avatar
Member
23 posts
Joined: Nov. 2011
Offline
Sorry, I dont get what you are saying… From what I see it is a Houdini problem (bug or known limitation in 11.1.64):

>> print u“hello world”
Traceback (most recent call last):
File “<console>”, line 1, in <module>
File “CPROGRA~1/SIDEEF~1/HOUDIN~1.67/houdini/python2.6libs\hou.py”, line 25114, in write
return _hou.ShellIO_write(*args)
TypeError: in method ‘ShellIO_write’, argument 2 of type ‘std::string const &’

:?:

Sebastian
User Avatar
Member
9 posts
Joined: Dec. 2011
Offline
Using Fedora 12

In an interactive python shell:
>>> print ‘Porks Werfect’
Porks Werfect
>>> print u'Porks Werfect'
Porks Werfect

In Autodesk Maya Script editor:
print ‘Porks Werfect’
Porks Werfect
print u'Porks Werfect'
Porks Werfect

In sideFX Houdini python shell:
>>> print ‘Porks Werfect’
Porks Werfect
>>> print u'Porks Werfect'
Traceback (most recent call last):
File “<console>”, line 1, in <module>
File “/opt/sidefx/hfs12.1.185/houdini/python2.6libs/hou.py”, line 28613, in write
return _hou.ShellIO_write(*args)
TypeError: in method ‘ShellIO_write’, argument 2 of type ‘std::string const &’

I'm not sure, but at a quick glance and not with full access to _hou.so, this in there within in reference to the error above :

invalid null reference in method ‘ShellIO_write’, argument 2 of type ‘std::string const &’

So perhaps it's only when unicode characters are somehow returning None, that this error comes up?

Nothing major, but it does require most multi-application debug verbosity to be modified explicitly for Houdini in order to get the full printout, so any insight into what the actual bug is will be helpful.
  • Quick Links