reading binary files as strings

This forum is currently in read-only mode.
From the Asset Store
This collection of music is the beautiful performance of rather small strings ensemble (8 first violins, 6 second violin
  • well, I'm trying to read a string from a jpeg file. the thing is, some image editors save a lot of useful data in the file (exif) which i'd like to read from my app. i was trying to open jpeg with editbox's load file action, no go. also i'm afraid this would be not so efficient. so is there any way to accomplish this one? the best way i'd like to do it is somehow read jpegs like windows' notepad does when you opens them. thanks in advance.

  • This is probably a job for The Pythons

  • well, how do I?

    i thought i'm fairly familiar with python, until my simple

    f = open("new.jpg", "r")
    text = f.read()
    f.close()
    EditBox.SetText(text)[/code:3fsqu5d5]
    
    did return some bull:!:hit. again, i'd like to read jpeg into editbox JUST LIKE windows' notepad does, halp plox  
    
    edit: "rb" mode also does not work
    
    edit2: of course .txt file are read with no problems :/
  • Hmm... using the Text Manipulator I can read the first line of a .jpg file (and it looks exactly like if you open in Notepad) but I can't seem to figure out how to read the rest of the lines

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You need to replace the NULL bytes (which automatically terminates a string) with something else.

    For example:

    f = open("python_error.jpg", "rb")

    text = f.read().replace('\x00','\x32')

    f.close()

    EditBox.SetText(text)

    Example .cap: http://www.box.net/shared/rkknb1p4uk

  • You need to replace the NULL bytes (which automatically terminates a string) with something else.

    For example:

    f = open("python_error.jpg", "rb")

    text = f.read().replace('\x00','\x32')

    f.close()

    EditBox.SetText(text)

    Example .cap: http://www.box.net/shared/rkknb1p4uk

    you, dear sir, just won one free internet. big love!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)