Thread JSON UTF decode (46 answers)
Opened by bianca at 2013-06-17 06:12

Gast wer
 2013-06-18 16:34
#168438 #168438
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sub iterate($$)
{
  my ($d, $c) = @_;

  if(ref $d eq 'ARRAY')
  {
    @$d=map{ iterate($_,$c) }@$d;
    return $d;
  }

  if(ref $d eq 'HASH')
  {
    while( my ($k,$v) = each %$d )
    { $d->{$k}=iterate($v,$c); }
    return $d;
  }

  return $c->($d);
}


Code (perl): (dl )
$content=iterate($content,sub{Encode::encode('ISO-8859-15',$_[0])})

Last edited: 2013-06-18 16:48:59 +0200 (CEST)

View full thread JSON UTF decode