Created
May 23, 2018 15:58
-
-
Save v3l0c1r4pt0r/c1cd55cf81f48ac13fbdd71ab8a57bd0 to your computer and use it in GitHub Desktop.
Script for generating test pages for line printers (dot-matrix) for sake of charset identification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# generate test page for printer | |
import os | |
a = b'' | |
for c in range(32,256): | |
a +=bytes([c]) | |
t = [] | |
for i in range(0,16): | |
t.append('x'+hex(i)[-1:]) | |
hdr = ' ' + ' '.join(t) + ' \r\n' | |
os.write(1, bytes(hdr, 'utf-8')) | |
b = a | |
os.write(1, b'') | |
os.write(1, b' ' + b'---'.join([b'+'] * 17)+b'\r\n') | |
s = int(0x20 / 0x10) | |
while len(b) > 0: | |
t=b[:16] | |
b=b[16:] | |
line = [] | |
for c in t: | |
line.append(bytes([c])) | |
os.write(1, bytes(hex(s)[-1:]+'x ','utf-8')) | |
os.write(1, b'| '+b' | '.join(line)+b' |') | |
os.write(1,b'\r\n') | |
os.write(1, b' ' + b'---'.join([b'+'] * 17)+b'\r\n') | |
s += 1 | |
os.write(1, b'\x0c') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment