comparison pytouhou/utils/helpers.py @ 0:6b2c7af2384c

Hello Gensokyo _o/
author Thibaut Girka <thib@sitedethib.com>
date Sun, 31 Jul 2011 21:32:12 +0200
parents
children ab826bc29aa2
comparison
equal deleted inserted replaced
-1:000000000000 0:6b2c7af2384c
1 def read_string(file, size, encoding=None):
2 data = file.read(size)
3
4 try:
5 data = data[:data.index(b'\x00')]
6 except ValueError:
7 pass
8
9 if encoding:
10 return data.decode(encoding)
11 else:
12 return data