Thread Hash im Methodenaufruf
(15 answers)
Opened by bianca at 2014-04-12 10:11
Ich würde statt
Code (perl): (dl
)
print JSON->new->$jsoncodierung->encode(\%hash); 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 my %hash = ( test => 'ÄÖÜß' ); my $encoding = 'utf8'; use JSON; package JSON; sub set_encoding { my $self = shift; my $encoding = shift; return eval "\$self->can($encoding) && \$self->$encoding"; } 1; my $json = JSON->new; $json->set_encoding($encoding) or warn "unknown encoding: $encoding"; print $json->encode(\%hash); print "\n"; $encoding = 'latin1'; $json->set_encoding($encoding) or warn "unknown encoding: $encoding"; print $json->encode(\%hash); print "\n"; $encoding = 'deutsch1968'; $json->set_encoding($encoding) or warn "unknown encoding: $encoding"; print $json->encode(\%hash); |