UTF-8 was designed so that character boundaries are easy to detect. To break a string into chunks of valid UTF-8, you can simply use the following:
my $utf8 = encode_utf8($text);
my @utf8_chunks = $utf8 =~ /\G(.{1,1024})(?![\x80-\xBF])/sg;
store($_) for @utf8_chunks;
store(decode_utf8($_)) for @utf8_chunks;
:
$ perl -e'
use Encode qw( encode_utf8 );
my $text = "\N{U+2660}" x 342;
my $utf8 = encode_utf8($text);
my @utf8_chunks = $utf8 =~ /\G(.{1,1024})(?![\x80-\xBF])/sg;
CORE::say(length($_)) for @utf8_chunks;
'
1023
3