[IronPython] how to change default encoding of string and file at runtime?
opin2 hu
opindd at hotmail.com
Sun Dec 25 08:02:48 CET 2005
I run IronPython0.9.6 in Win2000, System Default encoding is GBK(
simplified Chinese )
in IronPythonConsole:
>>>a= u'\u6211\u4eec'
>>>print a
>>>f = open("1.txt", "w")
>>>f.write( a )
>>>f.close()
open the file, only "??" in 1.txt
I grep "Encoding.ASCII" in source files,
then replace "Encoding.ASCII" with "Encoding.Default":
AST/Parser.cs line 44 System.Text.Encoding.ASCII ->
System.Text.Encoding.Default
Objects/PythonFile.cs line 202 Encoding.ASCII -> Encoding.Default
Objects/BaseStr.cs line 108 Encoding.ASCII -> Encoding.Default
Objects/BaseStr.cs line 188 Encoding.ASCII -> Encoding.Default
rebuild Ironpython, redo above test, everything works fine.
I don't know whether it is a right way to solve the problem?
how to change default encoding of string and file at runtime
_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
More information about the Ironpython-users
mailing list