Greetings, I have imported the third party libcurl library because the default httpmodule library of unreal is short of functionality. The problem I have encountered is that when I make requests the responses of everything are always with Chinese characters.
My log:
LogTemp: Warning: Response inside: 〴‰慂敒畱獥㩴椠癮污摩栠慥敤慮敭耀
LogTemp: Warning: Request Done Inside
LogTemp: Warning: 0
LogTemp: Warning: URL: 죐솣˕
LogTemp: Warning: Response:
LogTemp: Warning: Request Done
My code:
size_t writefunc(void* ptr, size_t size, size_t nmemb, std::string* s)
{
UE_LOG(LogTemp, Warning, TEXT("Response inside: %s"), static_cast<char*>(ptr));
UE_LOG(LogTemp, Warning, TEXT("Request Done Inside"));
return nmemb * size;
}
CURL *curl;
curl = curl_easy_init();
std::string* Lresponse_string;
LONG httpCode(0);
struct curl_slist* list = NULL;
list = curl_slist_append(list, "Accept: text / html, application / xhtml + xml, application / xml; q = 0.9, */*;q=0.8");
list = curl_slist_append(list, "User - Agent: Mozilla / 5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko / 20100101 Firefox / 6.0.2");
list = curl_slist_append(list, "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7");
curl_easy_setopt(curl, CURLOPT_URL, ("some_url"));
//curl_easy_setopt(curl, CURLOPT_URL, ("http://localhost:8000/index"));
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, ("GET"));
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list);
curl_easy_setopt(curl, CURLOPT_ENCODING, "identity");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writefunc);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &Lresponse_string);
CURLcode res = curl_easy_perform(curl);
UE_LOG(LogTemp, Warning, TEXT("%d"), res);
if (res == CURLE_OK) {
char* url = NULL;
FString* x;
curl_easy_getinfo(curl, CURLINFO_EFFECTIVE_URL, &x);
UE_LOG(LogTemp, Warning, TEXT("URL: %s"), &x);
UE_LOG(LogTemp, Warning, TEXT("Response: %s"), &Lresponse_string);
}
curl_easy_cleanup(curl);
Is there a solution to this problem? I can’t find the point of failure. If it is that I have imported libcurl wrong, unreal makes me the wrong conversion in the console or whatever?
Thanks for the help, greetings