http://www.perlmonks.org?node_id=1230633

morgon has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

say I have an utf-8 encoded string that I want to truncate to a certain number of bytes.

So I am looking for the longest substring that - when encoded as utf-8 takes less than a certain number of bytes.

What is the best way to do this?

Many thanks!