Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8078163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:42:15+00:00 2026-06-05T15:42:15+00:00

I am using a TEXT column which is ut8_unicode_ci in mysql to store some

  • 0

I am using a TEXT column which is ut8_unicode_ci in mysql to store some data that is scraped from over the internet.

The texts that are gathered are from various sites in different languages.

I am getting confused with the max length of 65535 bytes for a TEXT column.

How can I check that the strings I am inserting into the column do not go over that limit?

At the minute I am using strlen($str) to check the length of the strings, but by using this does it make sure it that the data will not be truncated to fit into the column as I understand utf8_unicode_ci can be more than 1 byte per character?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:42:16+00:00Added an answer on June 5, 2026 at 3:42 pm

    EDIT: The OP can simply use strlen() as it returns bytes, not characters. Witness:

    $ cat test.php
    #!/usr/bin/php -q
    <?php
    echo strlen("דותן כהן")."\n";
    echo mb_strlen("דותן כהן", "UTF-8")."\n";
    ?>
    
    $ ./test.php 
    15
    8
    

    Credit goes to deceze in a comment to this post.

    Old post below:

    The notes of the PHP manual have a handy function for determining how many bytes are in a string. It seems to be the only alternative to using MYSQL built in functions such as LENGTH to do the job, which would be cumbersome here.

    There are two other possible workarounds. Firstly, you can write the string to a file and check the file’s size. Secondly, you can force the ASCII encoding on mb_strlen and then it will treat each byte as a character, so the amount of characters that it returns is actually the amount of bytes. I haven’t tested this, so check it first. Let us know what works for you!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ssis package...which read data from fixed-column-width text file into DB table.
I am using TinyMCE for rich text editing of a column which I want
Using Access 2003 Date Column datatype is text Table1 Date 20090528 20090529 20090530 20090502
alt text http://img248.imageshack.us/img248/1797/updatetable.png Update Combined column using CategoryCode of every OrderId. In this example
I am trying to plot two columns from a text file using python matplotlib
I'm using Windows, and I would like to extract certain columns from a text
I am using Text::CSV::Slurp to create a CSV file from an array of hashes.
I've a datatable which has a single text column 'Title' which can have multiple
I am looking to create n-grams from text column in PostgreSQL. I currently split(on
I just read that the VARCHAR(MAX) datatype (which can store close to 2GB of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.