#!/bin/bash -

trs -e '
	&nbsp;		
	&iexcl;		
	&cent;		
	&pound;		
	&curren;	
	&yen;		
	&brvbar;	
	&sect;		
	&uml;		
	&copy;		
	&ordf;		
	&laquo;		
	&not;		
	&shy;		
	&reg;		
	&hibar;		
	&deg;		
	&plusmn;	
	&sup2;		
	&sup3;		
	&acute;		
	&micro;		
	&para;		
	&middot;	
	&cedil;		
	&sup1;		
	&ordm;		
	&raquo;		
	&frac14;	
	&frac12;	
	&frac34;	
	&iquest;	
	&Agrave;	
	&Aacute;	
	&Acirc;		
	&Atilde;	
	&Auml;		
	&Aring;		
	&AElig;		
	&Ccedil;	
	&Egrave;	
	&Eacute;	
	&Ecirc;		
	&Euml;		
	&Igrave;	
	&Iacute;	
	&Icirc;		
	&Iuml;		
	&ETH;		
	&Ntilde;	
	&Ograve;	
	&Oacute;	
	&Ocirc;		
	&Otilde;	
	&Ouml;		
	&times;		
	&Oslash;	
	&Ugrave;	
	&Uacute;	
	&Ucirc;		
	&Uuml;		
	&Yacute;	
	&THORN;		
	&szlig;		
	&agrave;	
	&aacute;	
	&acirc;		
	&atilde;	
	&auml;		
	&aring;		
	&aelig;		
	&ccedil;	
	&egrave;	
	&eacute;	
	&ecirc;		
	&euml;		
	&igrave;	
	&iacute;	
	&icirc;		
	&iuml;		
	&eth;		
	&ntilde;	
	&ograve;	
	&oacute;	
	&ocirc;		
	&otilde;	
	&ouml;		
	&divide;	
	&oslash;	
	&ugrave;	
	&uacute;	
	&ucirc;		
	&uuml;		
	&yacute;	
	&thorn;		
	&yuml;		
' |perl -ne '
s/&#([0-9]+);/
$1 < 0x100 ?
    $1 == 34 ? "&quot;" :
    $1 == 38 ? "&amp;" :
    $1 == 60 ? "&lt;" :
    $1 == 62 ? "&gt;" :
    chr ($1) :
$&/eg;
s/&#x([0-9A-Fa-f]+);/
$h = hex ($1);
$h < 0x100 ?
    $h == 34 ? "&quot;" :
    $h == 38 ? "&amp;" :
    $h == 60 ? "&lt;" :
    $h == 62 ? "&gt;" :
    chr ($h) :
$&/eg;
print;
'
