7

I have a table in sqlserver 2012 which may contain some questions in hindi font (web standard mangal font) like

  1. धर्मं,अर्थ, काम, मोक्ष क्या है?

A) आरोग्यमुल✔.

I want to retrieve the questions in php. I have developed a JSON web service in PHP to display the questions as per my knowledge I have put header

 ('Content-Type: application/json; charset=utf-8'); 

and

 echo json_encode($return_arr,JSON_UNESCAPED_UNICODE);

statement but still web service display ?????????? enter image description here symbols in behalf of hindi font. this problem only arise with sqlserver and php. if i have develop same web service in asp.net it work fine and if i have develop it in php with mysql database then again it works fine. I am unable to trace what is issue with sqlserver of php.enter image description here

7
  • use nvarchar for your data type in your database Commented Mar 17, 2016 at 6:38
  • Sir I have nvarchar(max) data type. i also created websrvice in asp.net. asp.net xml response give hindi out put but when i am convert the response into json then unable to display hindi Commented Mar 17, 2016 at 6:54
  • What happens if you don't convert to JSON but just directly write the data to your client? Does it still show 'garbled' or does it show correctly? Because that will indicate where your issue is. Commented Mar 17, 2016 at 7:42
  • 1
    sir i have solved the problem in asp.net web service by using this code : string jsonstring = UTF8Encoding.UTF8.GetString(ms.ToArray());. I have data in momery stream object. Now I am trying in php web service. please reply for PHP webservice . is any function in php like ASP.NET Commented Mar 17, 2016 at 8:00
  • 1
    Hello Everybody finally i have got the solution. Solution in php webservice is during creating the connection object of sqlserver you need to set CharacterSet for example : $connectionInfo = array( "UID"=>$uid, "PWD"=>$pwd, "Database"=>"schoolapp_db", "CharacterSet"=>"UTF-8"); Commented Mar 17, 2016 at 12:11

1 Answer 1

1

Hindi Text Solution in ASP.NET

I have solved the problem in asp.net web service by using this code : string jsonstring = UTF8Encoding.UTF8.GetString(ms.ToArray());. I have data in memory stream object.

Hindi Text Solution in PHP Web Service i have got the solution. Solution in php webservice is during creating the connection object of sqlserver you need to set CharacterSet for example : $connectionInfo = array( "UID"=>$uid, "PWD"=>$pwd, "Database"=>"schoolapp_db", "CharacterSet"=>"UTF-8");

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.