如何从 url 中获取 persian/arabic 个字符然后显示它

How to get persian/arabic characters from url and then show it

我已经编码了:

$url = "https://sitename.com/product-category/کتگوری";
$parsed = parse_url($url);
$path = $parsed['path'];
$path_parts = explode('/', $path);
$desired_output = $path_parts[2]; 
echo $desired_output;

现在返回的结果是这样的:%d8%a2%d9%86

指的是 کتگوری 但未正确显示。

所以我需要在 persian/arabic 个字符中正确显示 $desired_output

如何操作?

echo rawurldecode($desired_output);