The app receives request which looks like(http://127.0.0.1:8000/?type%3DGCPrint%26get%3DPaperNames%3A%E9%BB%98%E8%AE%A4%E6%89%93%E5%8D%B0%E6%9C%BA
) from client's XMLHttpRequest. The url is encoded by encodeURI() or encodeURIComponent() with javascript.
How can I get the canonical form url correctly?
I have reached the sdk and followed a demo, but the result is not correct, the last part of url is chinese characters.
Here is my test code
void UrlDecode()
{
wstring url = L"http://127.0.0.1:8000/?type%3DGCPrint%26get%3DPaperNames%3A%E9%BB%98%E8%AE%A4%E6%89%93%E5%8D%B0%E6%9C%BA";
DWORD bufSize = url.size()+1;
wstring buffer(url.size()+1, L'\0');
HRESULT hr = UrlCanonicalize(url.c_str(), &buffer[0], &bufSize, URL_UNESCAPE|URL_ESCAPE_UNSAFE);
if (SUCCEEDED(hr))
{
wcout.imbue(locale(""));
wcout<<buffer;
}
}
int _tmain(int argc, _TCHAR* argv[])
{
UrlDecode();
//system("pause");
return 0;
}
And the result is