Re: are there some special about '\x1a' symbol



On Sat, 10 Jan 2009 07:45:53 -0800, sim.sim wrote:

I had touch with some different python behavior: I was tried to write
into a file a string with the '\x1a' symbol, and for FreeBSD system, it
gives expected result:

open("test", "w").write('before\x1aafter') open('test').read()
'before\x1aafter'


but for my WinXP box, it gives some strange:

open("test", "w").write('before\x1aafter') open('test').read()
'before'

Here I can write all symbols, but not read. I've tested it with python
2.6, 2.5 and 2.2 and WinXP SP2.

Why is it so and is it possible to fix it?

\x1a is treated as "end of text" character in text files by Windows. So
if you want all, unaltered data, open the file in binary mode ('rb' and
'wb').

Ciao,
Marc 'BlackJack' Rintsch
.



Relevant Pages

  • Re: BrowseForFolder
    ... WinXp and a for root file selection in Win2k. ... present on all installations and is exposed through the comdlg32.ocx file. ... UserOpenDlg.initialDir= string ...
    (microsoft.public.scripting.vbscript)
  • Bound variables produce different result to fetching field by field
    ... we have come across the strangest problem and wondered if anyone else ... when we have a zero length character string that is NOT null ... version reports that the field is NULL. ... We also see a strange occurrence where sometimes the bound version ...
    (microsoft.public.data.odbc)
  • Re: DAO QueryDef - access thinks my column name is a parameter
    ... > It looks to me like access parses out the SQL finding to make them ... > parameters, but I have column names with strange names ... > compares a field's value to a string, and the string has lots of strange ... > Alex Black ...
    (microsoft.public.access.queries)
  • Re: works on console but not when writing to a string or file
    ... I would think that what's strange is that your code doesn't work, not that some other code does. ... System.Console.Write(Encoding.ASCII.GetString(data, offset, ... in the outputdata string the last packets gets chopped off. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: CListBox::DrawItem code
    ... That is really strange, but GetText returns me the same crap like getting ... I mean I pass some string using AddString. ... > But that really defeats the purpose of having an owner draw listbox, ... > to change the data that you are keeping in the itemData to include the ...
    (microsoft.public.vc.mfc)