#!/usr/bin/perl -w # Generate a screenful of characters. use strict; use constant WIDTH => 79; use constant HEIGHT => 22; # Convert code point to character sub EncodeChar($) { my ($code) = @_; if( $code <= (1 << 7) - 1 ) { return chr($code); } if( $code <= (1 << (5 + 6)) - 1 ) { return chr(0xc0 | (($code >> 6) & 0x1f)) . chr(0x80 | ($code & 0x3f)); } if( $code <= (1 << (4 + 6 + 6)) - 1 ) { return chr(0xe0 | (($code >> 12) & 0x0f)) . chr(0x80 | (($code >> 6) & 0x3f)) . chr(0x80 | ($code & 0x3f)); } return chr(0xf0 | (($code >> 18) & 0x07)) . chr(0x80 | (($code >> 12) & 0x3f)) . chr(0x80 | (($code >> 6) & 0x3f)) . chr(0x80 | ($code & 0x3f)); } for(my $y = 0; $y < HEIGHT; $y++) { for(my $x = 0; $x < WIDTH;) { if( $x == WIDTH - 1 || rand() < 0.5 ) { # Generate a half-width character. # # Select among the set of characters that are likely to confuse # escape code parsers. use constant DICTIONARY => "[]ABCD;0123456789"; print substr(DICTIONARY, int(rand(length(DICTIONARY))), 1); $x++; } else { # Generate a full-width character. # # Select among the squarish CJK characters use constant RANGE_START => 0x56d7; use constant RANGE_END => 0x571e; print EncodeChar(int(rand(RANGE_END - RANGE_START + 1)) + RANGE_START); $x += 2; } } print "\n"; }