use strict;

while(<>){
    print STDERR "$ARGV:$.: ", $&, " &#x", hex(ord($&)), ";\n" if /[\200-\377]/;
    s/([\200-\377])/esc($1)/ge;
      print;
    close ARGV if eof;
}

sub esc{
  my($c) = @_;
  return sprintf("&#x%04x;" , ord($c));
}
