truncate a mb-string to a given octet length?
| From: | Tom Worster | Date: | Fri, 12 Jun 2009 15:50:56 +0000 |
| Subject: | truncate a mb-string to a given octet length? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-293976@lists.php.net to get a copy of this message | ||
say a table in the db has a varchar(255) column, 255 being the max number of
octets of strings that can go in the column. now say the php script very
occasionally has to deal with utf8 input strings with octet length > 255 --
it needs to select rows matching the input string or insert the input
string.
so what i think i need is a function to truncate a utf8 string to the
longest valid utf8 string that has octet length <= 255.
is this what mb_strcut() is for? i'm having a hard time understanding the
man page for that function.