This is the input string that I entered in my HTML form:Why does a string with the same encoding renders differently on MySQL and HTML?
ラムダ計算(λ - 、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:
- Why does the field in MySQL database render differently from the ones in HTML?
- What can I do to catch the length in bytes of the above string to ensure it is within the 255 limit of
TINYTEXT
?
How about my second question? –
Because Unicode characters store 2-3 times more bytes than ASCII、You can probably only store up to 85 ** characters **、because they can be up to 255 ** bytes **。 Use an INT。 –
@Ben Since UTF-8 storage in MySQL in VARCHAR/TEXT columns is rather complex、I do not have an answer for that。 I'd suggest you do not limit yourself to TINYTEXT if you plan on storing anything more than a handful of characters。 – deceze