s/./sprintf('&#%03d', ord($&))/ge; [download]
In reply to Re: html2code.pl by Roy Johnson in thread html2code.pl by tcf03