如何在 php 上对 Shift_JIS 进行 urlencode?

How to urlencode on Shift_JIS on php?

你好,我有这个URL(网站字符集是Shift_JIS)

shop_search.php?pref=北海道**

但在尝试访问

之前应该将其转换为此
shop_search/shop_search.php?pref=%96k%8AC%93%B9**

我已经试过了,但没有成功:

您必须先从 SJIS 转换为 UTF-8,然后 url 对其进行编码,而不是从 UTF-8 转换为 SJIS,对吗?

如你所说"the website charset is Shift_JIS"。

<?php
$var = "北海道**";

$new = mb_convert_encoding($var, "SJIS", "UTF-8");

echo urlencode($new); // outputs %96k%8AC%93%B9%2A%2A
?>