[IronPython] Writing to a file with unicode name

Vernon Cole vernondcole at gmail.com
Fri Jul 9 18:51:50 CEST 2010

  One problem you may be having is with Python trying to escape the
backslashes in your Windows file name.  I tried a very simple test using the
Python "open" statement rather than any fancy .NET things. It created a file
with a japenese name on my Windows Vista laptop. Note that I used forward
(/) slashes where Windows users would expect a back (\) slash.

out = open(u"c:/temp/青山学院大学相模原キャンパス",'w')

The same code works in CPython, too.  If I remove the "u" unicode indicator
as in
then the same code will work in IronPython and Python 3.1, since it is
unnecessary in IPy and illegal in Python 3.

2010/7/9 abdalla ramadan <abdollaramadan.dev at gmail.com>

> Hello,
> I am trying to write to a file with the japanese name 青山学院大学相模原キャンパス
> The relative path I am passing to the methods is
> "output\url\c\青山学院大学相模原キャンパス"
> I used two methods
> s = StreamWriter(filenamenew, True, Encoding.UTF8)
> and
> outputfile = codecs.open(filenamenew, "w",'utf_8_sig')
> which both throwed the following exception:
> Unhandled Exception: System.ArgumentException: Illegal characters in path.
> Thanks very much for advance.
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100709/9d556147/attachment.html>

More information about the Ironpython-users mailing list