×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Aug 2007
    Location
    Lithuania
    Posts
    44

    Write Binary File

    Hello,
    how i can write binary data to file:
    f=open('c:\\a.bin','wb')
    f.write(chr(254))
    f.close()

    i get error ASCII decoding error

    and how find binary data in binary file ?
    Last edited by valdonas; 2009-03-31 at 07:56.

  2. #2
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,800

    Re: Write Binary File

    Quote Originally Posted by valdonas View Post
    Hello,
    how i can write binary data to file:
    f=open('c:\\a.bin','wb')
    f.write(chr(254))
    f.close()

    i get error ASCII decoding error

    and how find binary data in binary file ?
    As it says, it has a problem with decoding 254. Non-printable character?

    Works with other simple values,

    Try this,
    Code:
    f=open('c:\\a.bin','wb')
    f.write(chr(2)) #write ?
    f.close()
    Refer to the ASCII character map,
    http://www.danshort.com/ASCIImap/

    //Croozeus
    Pankaj Nathani
    www.croozeus.com

  3. #3
    Super Contributor
    Join Date
    May 2004
    Location
    Tampere, Finland
    Posts
    524

    Re: Write Binary File

    Quote Originally Posted by valdonas View Post
    Code:
     f=open('c:\\a.bin','wb')
     f.write(chr(254))
     f.close()
    Works fine here, using PyS60 1.4.2.

  4. #4
    Registered User
    Join Date
    Aug 2007
    Location
    Lithuania
    Posts
    44

    Re: Write Binary File

    and how i can write to file all characters ?

  5. #5
    Regular Contributor
    Join Date
    Mar 2003
    Location
    UK
    Posts
    125

    Re: Write Binary File

    Quote Originally Posted by valdonas View Post
    and how i can write to file all characters ?
    You mean a file containing every possible byte value?

    Code:
    f = open('myfile', 'wb')
    f.write(''.join(map(chr, range(256))))
    f.close()

Similar Threads

  1. How to Read / Write From/To TEXT file?
    By gb0071 in forum Symbian
    Replies: 6
    Last Post: 2009-03-04, 17:39
  2. Replies: 2
    Last Post: 2009-02-20, 15:58
  3. After writing file in binary format the file is reable
    By Rajani_sp in forum Symbian User Interface
    Replies: 6
    Last Post: 2007-11-22, 15:37
  4. Replies: 1
    Last Post: 2005-05-26, 14:22
  5. Write binary data in file
    By lazmous in forum Symbian
    Replies: 1
    Last Post: 2002-12-18, 02:07

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×