dongshandun4363 2013-03-11 16:36
浏览 51
已采纳

php json_encode用于android的欧元符号

I am loading data in an android app from a php service. In php i use json_encode to convert my data. Now i have a string with a character in it. json_encode converts this to \u0080, but as far as i know the actual correct unicode should be \u20AC. Usually thats not a problem but the Droid Sans Font does only render \u20AC as the euro symbol.

My question: Is there a way to make the character convert correctly (i dont care if thats in Javaor in PHP, although i would prefer a php solution) without using any string replaces or regex etc.. replacing seems ugly and there might be more symbols that dont get converted properly that i dont know of yet.

  • 写回答

1条回答 默认 最新

  • duanbei3747 2013-03-11 16:47
    关注

    \u0080 means that the input character was \x80 which is the Euro sign in Windows-1252. So I assume your string is encoded in this charset, then you should convert it to UTF-8 because json_encode only works with UTF-8 input:

    $string = iconv('Windows-1252', 'UTF-8', $string);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示