그래서 우리는 have 같은 기능 :하지만 창문내`std :: string url_encode_wstring (const std :: wstring & input)`을 리눅스에서 어떻게 만드나요?
이std::string url_encode_wstring(const std::wstring &input)
{
std::string output;
int cbNeeded = WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, NULL, 0, NULL, NULL);
if (cbNeeded > 0) {
char *utf8 = new char[cbNeeded];
if (WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, utf8, cbNeeded, NULL, NULL) != 0) {
for (char *p = utf8; *p; *p++) {
char onehex[5];
_snprintf(onehex, sizeof(onehex), "%%%02.2X", (unsigned char)*p);
output.append(onehex);
}
}
delete[] utf8;
}
return output;
}
그 화격자는 내가 궁금해 (그리고 가능)가 리눅스에서 작동되도록하려면?
'wcstombs'와'mbstowcs'를 사용하십시오. 몇 가지 예제 코드는 [이 대답에] (http://stackoverflow.com/questions/7141260/compare-stdwstring-and-stdstring/7159944#7159944)를보십시오. –