view pytouhou/utils/helpers.py @ 5:aa201d8cfc19

Fix camera handling, thanks, elghinn! Camera handling is done using a few magical values, which were obtained by dumping matrices using a modified wine installation, and then doing some maths.
author Thibaut Girka <thib@sitedethib.com>
date Tue, 02 Aug 2011 00:43:12 +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