add $prefix and $suffix to entity reference in &de_er.
authorimiyazaki <imiyazaki>
Wed, 22 Oct 2003 17:00:25 +0000 (17:00 +0000)
committerimiyazaki <imiyazaki>
Wed, 22 Oct 2003 17:00:25 +0000 (17:00 +0000)
Chise_utils/Chise_utils.pm

index 1c2aca0..2f40e75 100644 (file)
@@ -234,8 +234,11 @@ sub get_chars_for{
 sub de_er{
     my($er)=@_;
     my($output_char,$atr,$value);
+    my($prefix,$suffix);
+    $er=~/^(amp|&)?(.+?)(;)?$/
+       and $prefix=$1,$er=$2,$suffix=$3;
+    $prefix or $prefix="",$suffix or $suffix="";
     if($er=~/^\d+$/){
-       # only for debug.
        $output_char=pack("U",$er);
     }elsif($er=~/^U[\+\-]([a-fA-F\d]+)/){
        $output_char=pack("U",hex($1));
@@ -247,9 +250,9 @@ sub de_er{
        ($output_char)=&get_chars_matching($er_alias{$atr},$value);
     }
     if($output_char){
-      return $output_char;
+       return $output_char;
     }else{
-      return $er;
+       return $prefix.$er.$suffix;
     }
 }