Thread htmlspecialchars & Umlaute in Dtanebank speichern
(13 answers)
Opened by jonyder123 at 2008-01-04 13:15
da ich meistens sowieso mit CGI.pm arbeite, nehme ich meistens escapeHTML. Warum doppelt gemoppelt?
Hier ein Auszug aus escapeHTML: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 sub escapeHTML { # hack to work around earlier hacks push @_,$_[0] if @_==1 && $_[0] eq 'CGI'; my ($self,$toencode,$newlinestoo) = CGI::self_or_default(@_); return undef unless defined($toencode); return $toencode if ref($self) && !$self->{'escape'}; $toencode =~ s{&}{&}gso; $toencode =~ s{<}{<}gso; $toencode =~ s{>}{>}gso; if ($DTD_PUBLIC_IDENTIFIER =~ /[^X]HTML 3\.2/i) { # $quot; was accidentally omitted from the HTML 3.2 DTD -- see # <http://validator.w3.org/docs/errors.html#bad-entity> / # <http://lists.w3.org/Archives/Public/www-html/1997Mar/0003.html>. $toencode =~ s{"}{"}gso; } else { $toencode =~ s{"}{"}gso; } my $latin = uc $self->{'.charset'} eq 'ISO-8859-1' || uc $self->{'.charset'} eq 'WINDOWS-1252'; if ($latin) { # bug in some browsers $toencode =~ s{'}{'}gso; $toencode =~ s{\x8b}{‹}gso; $toencode =~ s{\x9b}{›}gso; if (defined $newlinestoo && $newlinestoo) { $toencode =~ s{\012}{ }gso; $toencode =~ s{\015}{ }gso; } } return $toencode; } ist also auch nix weltbewegendes, aber genĂ¼gen tuts trotzdem voll und ganz. |