# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Here are some translation tables to produce HTML encoded chars: %Huml = ( 'A' => 'Ä', 'a' => 'ä', 'E' => 'Ë', 'e' => 'ë', 'I' => 'Ï', 'i' => 'ï', 'O' => 'Ö', 'o' => 'ö', 'U' => 'Ü', 'u' => 'ü', ); %Hacu = ( 'A' => 'Á', 'a' => 'á', 'E' => 'É', 'e' => 'é', 'I' => 'Í', 'i' => 'í', 'O' => 'Ó', 'o' => 'ó', 'U' => 'Ú', 'u' => 'ú', ); %Hgra = ( 'A' => 'À', 'a' => 'à', 'E' => 'È', 'e' => 'è', 'I' => 'Ì', 'i' => 'ì', 'O' => 'Ò', 'o' => 'ò', 'U' => 'Ù', 'u' => 'ù', ); %Hcir = ( 'A' => 'Â', 'a' => 'â', 'E' => 'Ê', 'e' => 'ê', 'I' => 'Î', 'i' => 'î', 'O' => 'Ô', 'o' => 'ô', 'U' => 'Û', 'u' => 'û', ); %Hrin = ( 'A' => 'Å', 'a' => 'å', ); %Hsla = ( 'C' => 'Ç', 'c' => 'ç', 'O' => 'Ø', 'o' => 'ø', ); sub abc2html { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Convert all the escape sequences in an ABC string to their HTML encodings. # This is only done to title strings at present. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # local($s) = @_; $s =~ s#(\\)(["'`^])([aeiou])#&htmlenc($1,$2,$3)#ieg; # Marked vowels. $s =~ s#(\\)([co])#&htmlenc($1,'/',$2)#ieg; # C-cedille and o-slash. $s =~ s#(\\)(a)(a)#&htmlenc($1,$2,$3)#ieg; # Scand \aa notation. # $s =~ s#([aeiou])/#&htmlenc('',"'",$1)#ieg; # Gaelic V/ notation. return $s; } sub htmlenc { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Convert one escape sequence to its corresponging HTML encoding. If we can't # identify it, we return the original string. # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # local( $c1, # Escape char, used only when we fail. $c2, # The mark char, used to select a translate table. $c3) # The char to mark, used to select a table entry.. = @_; return($Huml{$c3} || "$c1$c2$c3") if ($c2 eq '"'); return($Hacu{$c3} || "$c1$c2$c3") if ($c2 eq "'"); return($Hgra{$c3} || "$c1$c2$c3") if ($c2 eq '`'); return($Hcir{$c3} || "$c1$c2$c3") if ($c2 eq '^'); return($Hrin{$c3} || "$c1$c2$c3") if ($c2 eq 'a' || $c2 eq 'A'); return($Hsla{$c3} || "$c1$c2$c3") if ($c2 eq '/'); return("$c1$c2$c3"); } 1;