'µg'字符随json_encode()丢失-PHP [英] 'µg' character getting lost with json_encode() -- php

查看:179
本文介绍了'µg'字符随json_encode()丢失-PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var_dump($array)可以很好地打印µg(微克)字符.当我使用echo json_ecode($array);打印相同的数组时,µg字符将替换为null.

var_dump($array) prints the µg (microgram) character fine. when I print the same array using echo json_ecode($array); , the µg character is replace with null.

如何正确编码字符串?

推荐答案

您必须使用 utf8_encode 正确编码要在JSON中使用的字符串.

You have to use utf8_encode to properly encode the string for use in JSON.

这篇关于'µg'字符随json_encode()丢失-PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆