[IronPython] How to convert a unicode variable to string?

Vizcayno vizcaynot at gmail.com
Tue Sep 23 15:52:03 CEST 2008

Is there a workaround to solve the next problem?

IronPython 2.0 Beta ( on .NET 2.0.50727.3053
Type "help", "copyright", "credits" or "license" for more information.
>>> a="Pitón"
>>> print str(a)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mscorlib", line unknown, in GetString
  File "mscorlib", line unknown, in GetChars
  File "mscorlib", line unknown, in Fallback
  File "mscorlib", line unknown, in Throw
UnicodeDecodeError: ('unknown', u'\xf3', 3, 4, '')

I python 2.5 I get:
>>> a = "Pitón"
>>> print str(a)

May be you will ask: why to do that? well,  what I want is to convert
any value a variable receives (float, unicode, int, string, etc) to a
string variable.
Many thanks for your time and help.

More information about the Ironpython-users mailing list