[IronPython] Writing to a file with unicode name
abdollaramadan.dev at gmail.com
Fri Jul 9 19:48:36 CEST 2010
Thank you very much for your reply.
Since the unicode text is not hard coded and is read from file I thought
line = line[0:-1]
will get rid of the new line character but it seemed I have to write
line = line.replace("\r","").replace("\n","")
now the code works correctly.
2010/7/9 Vernon Cole <vernondcole at gmail.com>
> 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>
>> I am trying to write to a file with the japanese name 青山学院大学相模原キャンパス
>> The relative path I am passing to the methods is
>> I used two methods
>> s = StreamWriter(filenamenew, True, Encoding.UTF8)
>> 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
> Users mailing list
> Users at lists.ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users