Python: Writing from a file to another produces chinese character in some cases
<p>I have a silly problem. I have an .ini file in which I need to replace some hardcoded paths but for some reason, just reading from this file and writing it to a new one produces chinese characters for some of the lines and I just can not explain why. I guess it is some sort of encoding issue but I can not understand why.</p>

<p>The smallest portion of code I can produce is just this:</p>

<pre><code>infFileOrg = open("orgFile.inf","r")

infFileModified = open("newFile.inf","w")

for line in infFileOrg.readlines():

  infFileModified.write(newLine)  #for now dont change anything just write the same line

infFileOrg.close()

infFileModified.close()
</code></pre>

<p>The original file looks like this (partially):</p>

<pre><code>[Version]

Signature="$Windows NT$"

Provider="Default Company Name"

CESignature="$Windows CE$"


[CEStrings]

AppName="xxx"

InstallDir=%CE1%\%AppName%

[Strings]

Manufacturer="Default Company Name"

[CEDevice]

VersionMin=4.0

VersionMax=6.99

BuildMax=0xE0000000
</code></pre>

<p>But just copying this to the new file gives me:</p>

<pre><code>[Version]

਍匀椀最渀愀琀甀爀攀㴀∀␀圀椀渀搀漀眀猀 一吀␀∀ഀഀ

Provider="Default Company Name"

਍䌀䔀匀椀最渀愀琀甀爀攀㴀∀␀圀椀渀搀漀眀猀 䌀䔀␀∀ഀഀ

਍嬀䌀䔀匀琀爀椀渀最猀崀ഀഀ

AppName="dacota"

਍䤀渀猀琀愀氀氀䐀椀爀㴀─䌀䔀㄀─尀─䄀瀀瀀一愀洀攀─ഀഀ

਍嬀匀琀爀椀渀最猀崀ഀഀ

Manufacturer="Default Company Name"

਍ഀഀ

[CEDevice]

਍嘀攀爀猀椀漀渀䴀椀渀㴀㐀⸀　ഀഀ

VersionMax=6.99

਍䈀甀椀氀搀䴀愀砀㴀　砀䔀　　　　　　　ഀഀ
</code></pre>

<p>It seems as every second line is messed up. Also when printing the text to the command prompt (Win32) there is a space between each character so it looks like it is reading two bytes at the time? I have not encountered this problem with other files before.</p>
