#!/usr/bin/perl -w # arch-tag: 4bd55861-bf0d-47dd-96ba-1083cd09c696 use strict; sub cquote { my $a = $_[0]; $a =~ s/^"/\\"/; $a =~ s/([^\\])"/$1\\"/g; return "\"$a\""; } my @v; while (<>) { next if /^RFC 1345/; next unless /^\s*(\S+)\s+([a-f0-9]{4})\s+(.*)$/; push @v, [$1,$2,$3]; } print map { my $c = eval("0x$_->[1]"); $c = ord(' ') if $c < 0x20 || ($c >= 0x7f && $c < 0xa0); if (length($_->[0]) < 2) { "" } else { sprintf "{ %7s, 0x%s }, /* %s %s */\n", (cquote($_->[0]), $_->[1], chr($c), $_->[2]) } } (sort {$a->[0] cmp $b->[0]} @v);