I have created an array in my codeigniter controller and encoded as json as follows :
$templateText = $this->input->post('sampletext');
$template_sample = $this->input->post('sampletext');
$postdata = array('userid' => LOGIN_FOR_TEMPLATE,
'password' => PASWD_FOR_TEMPLATE,
'template' => $templateText,
'template_sample' => $template_sample,
'callback_url' => base_url().'API/templateCallback'
);
$postdata = json_encode($postdata);
print_r($postdata);
if the $templateText is a unicode string, then the array is not encoded properly.
To test this I set this variable as :
$templateText = 'नये ऑफर 123';
$template_sample = 'नये ऑफर 123';
but my print_r() function display details as follows :
{"userid":"xxxx","password":"xxxx","template":"\u0928\u092f\u0947 \u0911\u092b\u0930 123","template_sample":"\u0928\u092f\u0947 \u0911\u092b\u0930 123","callback_url":"http:\/\/example.com\/API\/templateCallback"}
But I need to set it as 'नये ऑफर 123
like :
{"userid":"xxxx","password":"xxxx","template":"नये ऑफर 123","template_sample":"नये ऑफर 123","callback_url":"http://example.com/API/templateCallback"}
How do I solve this
I already set <meta charset="utf-8"> in my html