One of my app has links to Chinese websites. These websites use the GB2312 encoding. Unfortunately the .Net framework on WP7 does not support the GB2312 encoding, so the following function does not work.
private string ToGB2312(string character) {
byte[] bytes = System.Text.Encoding.GetEncoding("gb2312").GetBytes(character);
return '%' + BitConverter.ToString(bytes).Replace('-', '%');
}
Instead I'm going to use a web service to redirect the queries:
1. User clicks a link in my app (法)
2. App opens the browser on mysite.com/redirect?codepoint=%E6%B3%95
3. mysite.com redirects the user to chinesewebsite.com/page?codepoint=%B7%A8
That's because 法 is %E6%B3%95 in utf-8, and %B7%A8 in GB2312.
My question is, how do I do (3.)
in php?
Don't have a PHP environment now, can't test.
But I think you need these steps:
1. $gb = mb_convert_encoding(urldecode($_GET['codepoint']), 'GB2312', 'UTF-8');
2. $gb_url = urlencode($gb);
3. Redirect with $gb_url