im not too good when it comes to encoding, and I want to figure out how to return the data as the same encoding that it started with ...
I have a file with some characters, for example '»' , by the time I edited and entered into the database, which they turned into & Acirc; & raquo.
decode_entities () does nothing, and encode_entities encodes the characters again. Therefore, I created my own sub to fix this, but it assumes that when receiving data from a file, it is not extracted in the desired format.
my $file = "c:/perlscripts/" . md5_hex($md5Con) . "-code.php"; { local( $/ );
are there any encoding options, for example:
my $file = "c:/perlscripts/" . md5_hex($md5Con) . "-code.php"; { local( $/ );
and my sub:
sub unicodeConvert($) { my $str = shift; my %entityRef = ("&" => "&", '¢' => "¢", '¤' => "¤", '¦' => "¦", '¨' => "¨", 'ª' => "ª", '¬' => "¬", '®' => "®", '°' => "°", '²' => "²", '´' => "´", '¶' => "¶", '¸' => "¸", 'º' => "º", '¼' => "¼", '¾' => "¾", 'À' => "À", 'Â' => "Â", 'Ä' => "Ä", 'Æ' => "Æ", 'È' => "È", 'Ê' => "Ê", 'Ì' => "Ì", 'Î' => "Î", 'Ð' => "Ð", 'Ò' => "Ò", 'Ô' => "Ô", 'Ö' => "Ö", 'Ø' => "Ø", 'Ú' => "Ú", 'Ü' => "Ü", 'Þ' => "Þ", 'à' => "à", 'â' => "â", 'ä' => "ä", 'æ' => "æ", 'è' => "è", 'ê' => "ê", 'ì' => "ì", 'î' => "î", 'ð' => "ð", 'ò' => "ò", 'ô' => "ô", 'ö' => "ö", 'ø' => "ø", 'ú' => "ú", 'ü' => "ü", 'þ' => "þ", '¡' => "¡", '£' => "£", '¥' => "¥", '§' => "§", '©' => "©", '«' => "«", '¯' => "¯", '±' => "±", '³' => "³", 'µ' => "µ", '·' => "·", '¹' => "¹", '»' => "»", '½' => "½", '¿' => "¿", 'Á' => "Á", 'Ã' => "Ã", 'Å' => "Å", 'Ç' => "Ç", 'É' => "É", 'Ë' => "Ë", 'Í' => "Í", 'Ï' => "Ï", 'Ñ' => "Ñ", 'Ó' => "Ó", 'Õ' => "Õ", '×' => "×", 'Ù' => "Ù", 'Û' => "Û", 'Ý' => "Ý", 'ß' => "ß", 'á' => "á", 'ã' => "ã", 'å' => "å", 'ç' => "ç", 'é' => "é", 'ë' => "ë", 'í' => "í", 'ï' => "ï", 'ñ' => "ñ", 'ó' => "ó", 'õ' => "õ", '÷' => "÷", 'ù' => "ù", 'û' => "û", 'ý' => "ý", 'ÿ' => "ÿ"); while( ( my $key, my $obj ) = each( %entityRef ) ) { if( $key ne '&' ) { $str =~ s/$key/$obj/gis } else { $str =~ s