Index: D:/eclipse/7.3/server/Slim/Control/Request.pm =================================================================== --- D:/eclipse/7.3/server/Slim/Control/Request.pm (revision 23818) +++ D:/eclipse/7.3/server/Slim/Control/Request.pm (working copy) @@ -2220,7 +2220,9 @@ if (!ref($val)) { - ${$self->{'_params'}}{$key} = Slim::Utils::Unicode::decode($encoding, $val); + eval { ${$self->{'_params'}}{$key} = Slim::Utils::Unicode::decode($encoding, $val) }; + + $@ && $log->is_warn && $log->warn($@); } } } @@ -2279,7 +2281,7 @@ # no output next if ($key =~ /^__/); - $val = Slim::Utils::Unicode::encode($encoding, $val) if $encoding; + $val = Slim::Utils::Unicode::from_to($val, Slim::Utils::Unicode::encodingFromString($val), $encoding) if $encoding; if ($key =~ /^_/) { push @returnArray, $val; @@ -2302,10 +2304,7 @@ while (my ($key2, $val2) = each %{$hash}) { - if ($encoding) { - - $val2 = Slim::Utils::Unicode::encode($encoding, $val2); - } + $val2 = Slim::Utils::Unicode::from_to($val2, Slim::Utils::Unicode::encodingFromString($val2), $encoding) if $encoding; if ($key2 =~ /^__/) { # no output @@ -2324,8 +2323,8 @@ $val = join (',', @{$val}) } - if (ref $val eq 'SCALAR') { - $val = Slim::Utils::Unicode::encode($encoding, $val) if $encoding; + if ($encoding && ref $val eq 'SCALAR') { + $val = Slim::Utils::Unicode::from_to($val, Slim::Utils::Unicode::encodingFromString($val), $encoding); } if ($key =~ /^_/) { Index: D:/eclipse/7.3/server/Slim/Plugin/CLI/Plugin.pm =================================================================== --- D:/eclipse/7.3/server/Slim/Plugin/CLI/Plugin.pm (revision 23818) +++ D:/eclipse/7.3/server/Slim/Plugin/CLI/Plugin.pm (working copy) @@ -690,7 +690,7 @@ # bug 9559 - don't re-encode the response if we're using the requested locale $encoding = '' if $encoding eq Slim::Utils::Unicode::currentLocale(); - my @elements = $request->renderAsArray(); + my @elements = $request->renderAsArray($encoding); my $output = Slim::Control::Stdio::array_to_string($request->clientid(), \@elements); Index: D:/eclipse/7.3/server/Slim/Utils/Unicode.pm =================================================================== --- D:/eclipse/7.3/server/Slim/Utils/Unicode.pm (revision 23818) +++ D:/eclipse/7.3/server/Slim/Utils/Unicode.pm (working copy) @@ -908,6 +908,32 @@ return Encode::encode($encoding, $string); } + +=head2 from_to( $string, $from_encoding, $to_encoding ) + +=cut + +sub from_to { + my $string = shift; + my $from_encoding = shift; + my $to_encoding = shift; + + return $string unless $] > 5.007; + + return $string if $from_encoding eq $to_encoding; + + eval { + $string = decode($from_encoding, $string); + $string = encode($to_encoding, $string); + }; + + if ($@) { + Slim::Utils::Log->logger('server')->warn("Could not convert from $from_encoding to $to_encoding: $string ($@)"); + } + + return $string; +} + =head1 SEE ALSO L, L, L