JMSSerializer和UTF-8编码错误(Symfony2.4) [英] JMSSerializer and UTF-8 encoding error ( Symfony2.4 )
问题描述
我有REST api,可以返回任务/公司/便笺/等.在localhost上,无论我写什么任务描述或公司名称,它都可以正常工作,但是我将应用程序放在服务器上,并且当我使用łsignsążćę"之类的标志时,出现错误Your data could not be encoded because it contains invalid UTF8 characters." at app/endor/jms/serializer/src/JMS/Serializer/JsonSerializationVisitor.php line 36
.
I've got REST api which returns tasks/companies/notes/etc. On localhost it works fine, no matter what task description or company name I write, but I put my app on server and when I'm using signs like "łźążćę" there is error Your data could not be encoded because it contains invalid UTF8 characters." at app/endor/jms/serializer/src/JMS/Serializer/JsonSerializationVisitor.php line 36
.
数据库相同,表也相同,所有配置选项均相同.我该如何解决?
Databases are the same, tables too, all config options are the same. How can I fix this?
推荐答案
当我将@VirtualProperty与通过 substr(str,start,length)函数剪切字符串的方法一起使用时,我遇到了相同的错误. 如果使用UTF8,则此功能是错误的选择.而是使用 mb_substr .
I had the same error when I use @VirtualProperty with method which cut string with substr(str, start, length) function. This function is bad choice if you use UTF8. Instead, use mb_substr.
这篇关于JMSSerializer和UTF-8编码错误(Symfony2.4)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!