Bug with win32 open and utf-16 file
Tim Roberts
timr at probo.com
Tue Aug 26 02:06:53 EDT 2003
derek / nul <abuseonly at sgrail.org> wrote:
>
>>>>> data = file("c:/dash9.eng", "rb").read()
>>>>> data[-10:]
>>'\r\x00\n\x00)\x00\r\x00\n\x00'
>
>Interesting, I have just done the same and it would appear that the hexdump
>routine is changing 0d to 0a ???
I cut-and-pasted your version of hexdump onto my machine, fetched your
dash9.eng file, and ran this:
from hexdump import hexdump
f = open('dash9.eng','rb').read()
print hexdump(f)
The output seems to be exactly correct:
C:\tmp\x>python xxx.py|head
Dump of 32884 Bytes (type <type 'str'>)
$00000000 FFFE5300 49004D00 49005300 41004000 40004000 ..S.I.M.I.S.A.......
$00000014 40004000 40004000 40004000 40004A00 49004E00 ..............J.I.N.
$00000028 58003000 44003000 74005F00 5F005F00 5F005F00 X.0.D.0.t...........
$0000003C 5F000D00 0A000D00 0A005700 61006700 6F006E00 ..........W.a.g.o.n.
$00000050 20002800 20004400 61007300 68003900 0D000A00 ..(...D.a.s.h.9.....
$00000064 09006300 6F006D00 6D006500 6E007400 28004400 ..c.o.m.m.e.n.t.(.D.
$00000078 61007300 68002000 39002D00 34003400 43005700 a.s.h...9.-.4.4.C.W.
$0000008C 29000D00 0A000900 54007900 70006500 20002800 ).......T.y.p.e...(.
$000000A0 20004500 6E006700 69006E00 65002000 29000D00 ..E.n.g.i.n.e...)...
I get the same result if I cast the string to a list.
What version of Python are you using?
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list