Search code examples
phpencodingcharacter-encodingurl-encoding

(PHP) What encoding scheme is this (like percent encoding)?


(PHP) I came cross this encoding scheme trying to submit HTTP queries to a Chinese website (Taiwan traditional Chinese, or BIG5 which is the encoding of the website).

The search string is 兩岸知識產權發展研究 and it's encoded and posted as the following col=1&keyword=%A8%E2%A9%A4%AA%BE%C3%D1%B2%A3%C5v%B5o%AEi%AC%E3%A8s&x=33&y=5

I assume "%A8%E2%A9%A4%AA%BE%C3%D1%B2%A3%C5v%B5o%AEi%AC%E3%A8s" is "兩岸知識產權發展研究" encoded, it looks a lot like percent encoding but it isn't. I wonder what this encoding scheme is, and how I can encode a string this way in PHP.


Solution

  • It's called url encoding, you can use PHP's urlencode() function for this duty. (And check out urldecode() if you need to decode it.)