Files
the-biergarten-app/pipeline/src/web_client/curl_web_client_url_encode.cpp
2026-04-09 17:19:04 -04:00

24 lines
597 B
C++

/**
* @file web_client/curl_web_client_url_encode.cpp
* @brief CURLWebClient::UrlEncode() implementation.
*/
#include <curl/curl.h>
#include <stdexcept>
#include <string>
#include "web_client/curl_web_client.h"
std::string CURLWebClient::UrlEncode(const std::string& value) {
// A NULL handle is fine for UTF-8 encoding according to libcurl docs.
char* output = curl_easy_escape(nullptr, value.c_str(), 0);
if (output) {
std::string result(output);
curl_free(output);
return result;
}
throw std::runtime_error("[CURLWebClient] curl_easy_escape failed");
}