在 Windows Phone 开发中,我想用以下代码编码的 utf8 编写一个 URI,但失败了。结果仍然是 unicode 但不是 %D6%DC 的形式...
byte[] unicodeBytes = Encoding.Unicode.GetBytes(str);
byte[] utf8bytes = Encoding.Convert(Encoding.Unicode, Encoding.UTF8, unicodeBytes);
char[] utf8Chars = new char[Encoding.UTF8.GetCharCount(utf8bytes, 0, utf8bytes.Length)];
Encoding.UTF8.GetChars(utf8bytes, 0, utf8bytes.Length, utf8Chars, 0);
string utf8string = new string(utf8Chars);
var URI = new Uri("http://www.jpwy.net/gc/search.php?" + utf8string);
这有什么问题?