diff options
author | wm4 <wm4@mplayer2.org> | 2012-07-28 23:02:52 +0200 |
---|---|---|
committer | wm4 <wm4@mplayer2.org> | 2012-07-28 23:36:08 +0200 |
commit | 1ee740cceb2050821c772a574ea984f96389fa29 (patch) | |
tree | 3a763063aaaecd5774f130d441d399a7e5cca2e8 /TOOLS | |
parent | 85a3a0d5bc1294f88dea42a515bb3dce16c9d951 (diff) | |
download | mpv-1ee740cceb2050821c772a574ea984f96389fa29.tar.bz2 mpv-1ee740cceb2050821c772a574ea984f96389fa29.tar.xz |
TOOLS/fil2string.py: fix for use with binary files
The script was written to be able to deal with binary files, but it had
a bug corrupting some data: e.g. a byte sequence 0x1 0x37 was printed as
"\17" (0x1 = escaped as "\1", and 0x37 = kept as literal "7"), which
would be interpreted as single character 0xF.
Always pad octal literals to length 3, which makes the escape sequences
unambiguous.
Diffstat (limited to 'TOOLS')
-rwxr-xr-x | TOOLS/file2string.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/TOOLS/file2string.py b/TOOLS/file2string.py index 002ba4ab60..cb121e4884 100755 --- a/TOOLS/file2string.py +++ b/TOOLS/file2string.py @@ -8,7 +8,7 @@ import sys def main(infile): - conv = ['\\' + oct(c)[2:] for c in range(256)] + conv = ['\\' + ("%03o" % c) for c in range(256)] safe_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" \ "0123456789!#%&'()*+,-./:;<=>?[]^_{|}~ " for c in safe_chars: |