duanchongzi9997 2011-11-12 11:12 采纳率: 0%
浏览 64
已采纳

为什么具有相同编码的字符串在MySQL和HTML上的呈现方式不同?

This is the input string that I entered in my HTML form:

람다 대수(λ -, lambda -)는 함수 정의, 함수 적용, 귀납적 함수를 수식으로 표현하기 위한 형식 체계이다. 1930년대 알론조 처치가 수학기초론을 연구하는 과정에서 람다 대수의 형식을 제안하

This is the string that appears in MySQL database field of TINYTEXT type:

람다 대수(λ -, lambda -)는 함수 ì •ì˜, 함수 ì ìš©, ê·€ë‚©ì  í•¨ìˆ˜ë¥¼ 수ì‹ìœ¼ë¡œ 표현하기 위한 í˜•ì‹ ì²´ê³„ì´

This is the output on the HTML page upon querying:

람다 대수(λ -, lambda -)는 함수 정의, 함수 적용, 귀납적 함수를 수식으로 표현하기 위한 형식 체계이

Both the HTML and the database are encoded in UTF-8. There are two things which I would like to ask:

  1. Why does the field in MySQL database render differently from the ones in HTML?
  2. What can I do to catch the length in bytes of the above string to ensure it is within the 255 limit of TINYTEXT?
  • 写回答

1条回答 默认 最新

  • douyi6168 2011-11-12 11:19
    关注

    Most likely the most common pitfall: You're not setting your database connection to the right encoding. See why do i have to use mb_convert_encoding($name,'ISO-8859-15','utf-8') to get accented chars to display?.

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

报告相同问题?

悬赏问题

  • ¥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文件加载里面的的资源