view pytouhou/utils/helpers.py @ 45:e01e88b06a13

Fix camera handling, should be much closer to the original, now
author Thibaut Girka <thib@sitedethib.com>
date Mon, 22 Aug 2011 09:11:16 +0200
parents 6b2c7af2384c
children ab826bc29aa2
line wrap: on
line source

def read_string(file, size, encoding=None):
    data = file.read(size)

    try:
        data = data[:data.index(b'\x00')]
    except ValueError:
        pass

    if encoding:
        return data.decode(encoding)
    else:
        return data