Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deal with hindi font using sqlserver and php?

Tags:

php

sql-server

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

like image 750
Rai Singh Avatar asked Mar 17 '16 05:03

Rai Singh


1 Answers

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");

like image 64
Rai Singh Avatar answered Nov 20 '22 18:11

Rai Singh