Help for this page

Select Code to Download


  1. or download this
    my $to_entitise = q{<>&"'}; # Unsafe for HTML
    
    my $decoded_text = decode('UTF-8', $utf8_text);
    my $decoded_html = encode_entities($decoded_text, $to_entitise);
    my $latin1_html = encode('iso-latin-1', $decoded_html, Encode::FB_HTML
    +CREF);
    
  2. or download this
    my $to_entitise =
       q{<>&"'} .              # Unsafe for HTML
    ...
    my $decoded_text = decode('UTF-8', $utf8_text);
    my $decoded_html = encode_entities($decoded_text, $to_entitise);
    my $latin1_html = encode('iso-latin-1', $decoded_html);
    
  3. or download this
    my $decoded_text = decode('UTF-8', $utf8_text);
    my $decoded_html = encode_entities($decoded_text);
    my $latin1_html = encode('iso-latin-1', $decoded_html);
    
  4. or download this
    my $to_entitise = q{\x{100}-\x{1FFFFF}};  # Not present in iso-8859-1
    
    my $decoded_html = decode('UTF-8', $utf8_html);
    $decoded_html = encode_entities($decoded_html, $to_entitise);
    my $latin1_html =  encode('iso-latin-1', $decoded_html);
    
  5. or download this
    use charnames      qw( :full );  # For \N on older Perls
    use Encode         qw( encode decode );
    ...
    
    my $utf8_text = encode('UTF-8', "a\N{U+00E9}\N{U+2660} 1<4");
    my $utf8_html = encode('UTF-8', "a\N{U+00E9}\N{U+2660} <b>foo</b>");