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

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


Hello:
Is there a workaround to solve the next problem?

.ipy
IronPython 2.0 Beta (2.0.0.5000) 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)
Pitón
>>>

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.
Vizcayno.



More information about the Ironpython-users mailing list