dpv21589 2013-04-10 00:01
浏览 38
已采纳

mb_convert_case删除Unicode字符? [重复]

This question already has an answer here:

My code:

echo mb_convert_case('Björk Guðmundsdóttir', MB_CASE_UPPER, 'UTF-8');
echo mb_convert_case('Björk Guðmundsdóttir', MB_CASE_LOWER, 'UTF-8');

and the output:

BJRK GUMUNDSDTTIR
bjrk gumundsdttir

Some characters were deleted. Anyone know why?

UPDATE 1:

I noticed that my PHP file was note saved as UTF-8. So, I saved it as UTF-8 and ran the code again. My new results:

BJÖRK GUÃMUNDSDÓTTIR
björk guðmundsdóttir

UPDATE 2:

I guess the problem was just that it was being displayed weird in the browser. Solved by adding header('Content-Type: text/html; charset=utf-8');

</div>
  • 写回答

1条回答 默认 最新

  • douwang6635 2013-04-10 00:33
    关注

    Firstly make sure your editor is set to UTF-8 without BOM, then you must make sure that the text you passed to the function is actually UTF-8, since that is what you specified as the third argument. Then it should work

    EDIT: You might also want to check that your browser is interpreting the characters correctly and make sure the page is setting the content-type, using either a <meta> tag or PHPs header()

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)