Thread HTML::Entities - decode_entities() erzeugt kein Unicode sondern Latin1 (40 answers)
Opened by GwenDragon at 2024-03-19 12:49

GwenDragon
 2024-03-19 12:49
#195938 #195938
User since
2005-01-17
14563 Artikel
Admin1
[Homepage]
user image
HTML::Entities::decode_entities soll laut Perldoc Unicode erzeugen.
Quote
decode_entities( $string, ... )
This routine replaces HTML entities found in the $string with the corresponding Unicode character.
https://metacpan.org/release/OALDERS/HTML-Parser-3...

Tut es aber nicht.

Code (perl): (dl )
1
2
3
4
5
use strict; use warnings; use 5.020;
use utf8;
use HTML::Entities ();
my $s = HTML::Entities::decode_entities("ä");
say $s =~ /\xE4/;

Ergibt 1.
Aber \xE4 ist eben das ä in Latin1 und nicht Unicode.

Linux Perl 5.36
HTML::Parser ist 3.81

Das ist ganz besonders toll, wenn es Daten gibt die sowohl UTF-8 kodiert sind und HTML-Entity-kodiert. :-(

Hat jemand eine Lösung parat?
Last edited: 2024-03-19 13:04:20 +0100 (CET)
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

View full thread HTML::Entities - decode_entities() erzeugt kein Unicode sondern Latin1