I need to pull strings out of a database and format them for display on a web page. Individually this is not a problem, but the strings are in various formats in the database and I'm having trouble figuring out a sequence of conversions that will handle all inputs. The strings are mostly ascii, but some of them have special characters embedded.
The below program creates a sample array of characters from the database, then converts them to html. I manually figured out what needs to be done to each character. I need to replace the noted two lines with something that can automatically handle the various formats.
use feature 'say';
use Encode qw(decode encode);
my @in = (chr(226).chr(152).chr(134), chr(195).chr(161), chr(150), chr
+(153), '®', '&', 'Æ', chr(63743), chr(991), chr(9760));
decode_entities($_) for @in;
#The below two lines need to be replaced
$in[$_] = decode ('utf8', $in[$_]) for 0..1;
$in[$_] = decode ('cp1252', $in[$_]) for 2..3;
say encode_entities($_) for @in;
Thank you for any assistance you can render.