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?.

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

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line