On Monday 09 May 2005 12:24, John Doe wrote:
> Am Montag, 9. Mai 2005 11.55 schrieb Andreas Steichardt:
> > Hi!
> >
> > We are storing UTF-8 data in out mysql database and we need to get the
> > length of the data. But length() doesn't return the number of characters
> > but the pure number of bytes.
> >
> > SELECT LENGTH('köter') => 6
> >
> > Currently we are doing something like that:
> >
> > SELECT LENGTH(CONVERT('köter' USING 'ucs2'))/2;
> >
> > This works fine but a "real" solution like CHAR_LENGTH() or something
> > like that would be really apprectiated.
>
> From http://dev.mysql.com/doc/mysql/en/string-functions.html:
>
> CHAR_LENGTH(str)
>
> Returns the length of the string str, measured in characters. A multi-byte
> character counts as a single character. This means that for a string
> containing five two-byte characters, LENGTH() returns 10, whereas
> CHAR_LENGTH() returns 5.
>
>
> joe

lol....must have been blind as i definately looked in the manual 
(interestingly the function is named as i suggested ;) )...

Thanks for the hint and sorry for my blindness,

 Andreas Streichardt


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to