Php 从SQL SERVER数据库检索东亚语言数据
目前,我使用PHP3.5从SQL Server获取数据,并以Json格式返回。但在我的数据库中,我有不同语言的数据,如汉语、泰语、日语、韩语等。当我返回数据时,它以这种格式显示:?? 如何以原始格式显示数据? 下面是我的代码:Php 从SQL SERVER数据库检索东亚语言数据,php,json,sql-server-2012,Php,Json,Sql Server 2012,目前,我使用PHP3.5从SQL Server获取数据,并以Json格式返回。但在我的数据库中,我有不同语言的数据,如汉语、泰语、日语、韩语等。当我返回数据时,它以这种格式显示:?? 如何以原始格式显示数据? 下面是我的代码: $query = "SELECT [name] ,[venue] FROM tablename
$query = "SELECT
[name]
,[venue]
FROM tablename
WHERE id = '2'";
/**********************************************/
//Just for the Purpose of Count Number of Rows
$params = array();
$options = array( "Scrollable" => SQLSRV_CURSOR_KEYSET );
/******************************/
#Query the database to get the user details.
$res = sqlsrv_query($conn, $query, $params, $options);
$arr = array();
#If no data was returned, check for any SQL errors
if ($res == false)
{
echo 'Query not Executed : '. die(print_r(sqlsrv_errors(), TRUE));
}
else
{
while($obj = sqlsrv_fetch_array($res, SQLSRV_FETCH_ASSOC))
{
$arr[] = array(
"name" => $obj['name'],
"venue" => $obj['venue']
);
}
}
header('Content-type: application/json; charset=utf-8');
#Output the JSON data
echo json_encode($arr);
exit();
sqlsrv_free_stmt($res); // Closes a statement. Frees all resources associated.
sqlsrv_close($conn); // Closes a connection. Frees all resources associated.
您是否尝试过下面的代码
echo json_encode($arr,JSON_UNESCAPED_UNICODE);
@Sirinat Paphatsirinatthi我当前的PHP版本是3.5,我不这么认为,它支持JSON\u UNESCAPED\u unicode。您能将该版本更新到最新版本吗?我认为会更好。@Sirinat Paphatsirinatthi目前有点困难,因为我没有服务器访问权限。哦,解决这个问题很困难,因为你的PHP版本过时了。等待另一个。希望你能解决soon@SirinatPaphatsirinatth好的,做一件事,请喜欢这篇文章,这样我就可以去聊天了,因为我在通过Stackoverflow聊天时没有那么出名。谢谢