Maybe a solution would be to recursively walk the <code>$params</code>, ensure that everything is UTF-8 encoded and then encode it as JSON (also this might also be a little too much overhead).
Another solution might be to replace <code>json_encode</code> by another serialization/output function.