#!/usr/bin/env python # demo python prog to convert a byte stream # to something displayable on a utf8 terminal import sys try: rand_file=open("/dev/urandom") while 1: chunk=rand_file.read(4096) if chunk == '': break uc=unicode(chunk,"latin-1") #A0-FF -> latin1 uc=uc.translate(range(0x2400,0x2420) #00-19 -> unicode control pictures +range(0x20,0x7F) #ascii -> ascii +[0x2421] #DEL -> unicode control picture +range(0x20,0x40)) #80-9F -> ascii sys.stdout.write(uc.encode("utf-8")) except: #ctrl-c print sys.exit(0)