我的是linux系統(tǒng) php7.2
GatewayWorker tcp 上傳json數(shù)據(jù)帶有中文字符的顯示為空
這是什么問題
{"method":"imvoice","Devices":"sss121","voicetext":"你好嗎哈哈哈"}
json需要utf-8編碼,文件編碼和網(wǎng)頁編碼改成utf-8試下。
<?php
header('Content-type: application/json;charset=utf-8');
use \GatewayWorker\Lib\Gateway;
use \GatewayWorker\Lib\Db;
class Events
{
public static function onConnect($client_id)
{
echo"client:{$_SERVER['REMOTE_ADDR']}:{$_SERVER['REMOTE_PORT']} gateway1:{$_SERVER['GATEWAY_ADDR']}:{$_SERVER['GATEWAY_PORT']} client_id:$client_id\n";
}
public static function onMessage($client_id, $message){
$db = Db::instance('db');
echo "client:{$_SERVER['REMOTE_ADDR']}:{$_SERVER['REMOTE_PORT']}
gateway2:{$_SERVER['GATEWAY_ADDR']}:{$_SERVER['GATEWAY_PORT']} $message\n";
好像還不行 gateway2:{$_SERVER['GATEWAY_ADDR']}:{$_SERVER['GATEWAY_PORT']} $message\n"; 中文就是不顯示 如果是其他字符就可以,或者吧中文轉(zhuǎn)成unicode編碼 也可以,就是純中文死活不顯示