dscjp19831212 2013-10-16 17:55
浏览 25
已采纳

javascript,php,html和mysql查询中的多语言字符

I'm creating a website currently where one of the features is allowing the user to edit any text in a contenteditable div that they would like. This text would later be posted in json format by jQuery to a PHP script which either inserts or updates the record in the mysql database.

Everything is working fine in the English alphabet. But there will be multilingual users that will use the site. are there any languages that I would need to have special support for in any part of the process I described above?

The main thing that I am worried about is the database collation/field type.

I have tried to test this as well as possible but I was wondering if anyone has had any problems with characters from other languages. Thanks in advance.

  • 写回答

2条回答 默认 最新

  • dousao1175 2013-10-16 18:04
    关注

    While creating database set the character set to utf-8. example

    CREATE DATABASE db_name
    CHARACTER SET utf8
    DEFAULT CHARACTER SET utf8
    COLLATE utf8_general_ci
    DEFAULT COLLATE utf8_general_ci
    

    Use mysqli_set_charset($connection, "utf8") before updating data to/from MySQL

    Use headerheader('Content-type: text/html; charset=UTF-8') ;

    or meta tags like

    <meta http-equiv="Content-type" value="text/html; charset=UTF-8" />

    If you are using ajax to update the content, there shouldn't be any issues as W3C states that ajax data charset is always utf-8

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

报告相同问题?

悬赏问题

  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源