Re: substr and UTF-8
| From: | Jochem Maas | Date: | Wed, 30 Aug 2006 11:51:38 +0000 |
| Subject: | Re: substr and UTF-8 | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-241221@lists.php.net to get a copy of this message | ||
Peter Lauri wrote:
> Hi group,
>
> I want to limit the number of characters that are shown in a script. The
> characters happen to be Thai, and the page is encoded in UTF-8. Everything
> works, except when I want to cut the text (just take start of string).
>
> I do:
>
> echo substr($thaistring, 0, 30);
>
> The beginning of the string works fine, but the last character does mostly
> "break". How can I determine the start and end of a character.
become familiar with (and install) the mb_string extension
>
> I hope the problem is clear enough, is it? :)
>
> Best regards,
> Peter Lauri
>
> www.lauri.se - personal web site
> www.dwsasia.com - company web site
>