how to add Chinese character to http_client?

Jan 27, 2015 at 8:45 AM
Edited Jan 27, 2015 at 8:54 AM
I need to add an Chinese character to http_client, but the http_client constructor throw an error,
"Microsoft C++ exception: web::uri_exception at memory location 0x000000B6914BDA80"
Here is the simplified program:
wstring realName =L"李强" ; // this is an chinese character
wstring client_wtr = L"https://transaction/rest/WalletWS/"+ realName ;
http_client client(client_wtr);   throw an error!
I have tried many ways, like "utility::conversions::default_code_page_to_utf16" to convert the realName, but no use. sometimes the http_client constructor will go through, but the http server(java written) will get like "LMEk" English character.

Thanks for any help!
Jan 27, 2015 at 5:32 PM
Hi ylongwu,

Unicode characters are not allowed in URLs, ASCII characters must be used. What you need to do is percent encode the Unicode characters. We have functions for helping to accomplish this in the library. I believe you want to pass the 'realName' variable to the web::uri::encode_data_string(...) API.