Mysql max length on columns and ensure that I don't go over this limit using utf8_unicode_ci - PHP?

I use the column TEXTthat ut8_unicode_ciin mysql to store some data that is cleared due to the internet.

Texts that are collected from different sites in different languages.

I am confused with the maximum 65535byte length for a column TEXT.

How can I verify that the rows that I insert in a column do not meet this limit?

At that moment, when I use strlen($str)to check the length of the rows, but using this, make sure that the data will not be truncated to fit into the column, as I understand it. utf8_unicode_cicould be more than 1 byte per character?

+5
source share
2

EDIT: OP strlen(), , . :

$ cat test.php
#!/usr/bin/php -q
<?php
echo strlen("Χ“Χ•Χͺן Χ›Χ”ΧŸ")."\n";
echo mb_strlen("Χ“Χ•Χͺן Χ›Χ”ΧŸ", "UTF-8")."\n";
?>

$ ./test.php 
15
8

deceze .

:

PHP . , MYSQL , LENGTH , .

. -, . -, ASCII mb_strlen, , . , . , !

+3

MySQL LENGTH():

str, . . , , LENGTH() 10, CHAR_LENGTH() 5.

0

All Articles