duanreng3439 2009-01-15 14:49
浏览 21
已采纳

字符集困境

I have a small ajax application built with php.

Using phpMyAdmin I have set a mysql database to utf-8, and have imported a textfile containing utf-8 data into it.

This worked fine on a windows machine with easyphp, after adding character-set-server=utf8 and default-character-set=utf8 to the my.cnf file.

I have now tried to move this to a production server where I do not have access to the configuration file, and characters such as umlauts are not displayed.

Is there something that can be set in the php code(not the configuration file) to fix this, or some command I can give to mysql?

I tried ALTER DATABASE vweb_50 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin with phpMyAdmin to try from utf8_general_ci but it made no difference.

  • 写回答

2条回答 默认 最新

  • drccfl9407 2009-01-15 14:59
    关注

    There's a couple of things to be done here, and I'm not sure I understand your problem correctly, but if I do, I think most of it can be addressed with the PHP functions utf8_encode and utf8_decode:

    • utf8_encode
      • Encodes an ISO-8859-1 string to UTF-8
    • utf8_decode
      • This function decodes data , assumed to be UTF-8 encoded, to ISO-8859-1.

    Also, look into htmlentities if needed.

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

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥15 深度学习残差模块模型
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)