CURL changes non-english characters when opening url

admin

Administrator
Staff member
I'm trying to open an url with curl end echo the text in that page. The url is sends parameters to the python script and it creates a file according to the parameters. So, i'm sending parameters to wordpress function via ajax, this parts works, it gets parameters without any error, then i'm creating url with this and using curlopt_url to open it in backend. Then echo response to send data to ajax.

Code:
  function my_function() {
  $param1 = $_REQUEST['p1'];
  $param2 = $_REQUEST['p2'];
  $url = "http://localhost:1234/handle?a=$param1&b=$param2";
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_VERBOSE, true);
  curl_setopt($ch, CURLOPT_URL, $url);
  $store = curl_exec ($ch);
  echo substr($store, 1);
  curl_close ($ch); exit();

Assume that p2 contains non-english characters like ş,ğ,ı etc.. The function gets it correctly (I can see it when i echo $url instead of response), but in CURLOPT_URL part they are changing.
Additionally, when i open url form browser, it works fine.