dongnuo6310 2012-09-11 22:15
浏览 334
已采纳

web服务器上使用的file_put_contents编码?

I am trying to use file_put_contents (and file_get_contents for that matter) with a UTF-8 ¥ following this stackoverflow post: How to write file in UTF-8 format? which uses:

$data = mb_convert_encoding($data, 'UTF-8', 'OLD-ENCODING');

Which wasn't really explained well, since it produces an error of:

mb_convert_encoding(): Illegal character encoding specified

So 'OLD-ENCODING' was just a placeholder they were using. The question I have is what encoding should I change this to? ASCII or ISO-8859-1? What encoding do most web hosts use? Does it matter?

When I open the file, I will get the symbol correctly, only if I have my notepad set with encoding UTF-8. If I open it with another character set it will show up with a "?".

  • 写回答

2条回答 默认 最新

  • doushi1964 2012-09-11 22:20
    关注

    Try without third parameter.

    $str = mb_convert_encoding($str, "UTF-8");
    

    Or auto:

    $str = mb_convert_encoding($str, "UTF-8", "auto");
    

    More info and examples on: http://php.net/manual/function.mb-convert-encoding.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度