The only correct approach for UTF-8 strings in Perl

Yuki Kimoto - SPVM Author - May 26 '23 - - Dev Community

The only correct approach for UTF-8 strings in Perl.

A string is treated as byte sequences without any flags.

Separate functions that handle UTF-8 from functions that handle byte sequences. The following is an example of the substr function.

substr_bytes
substr_utf8
Enter fullscreen mode Exit fullscreen mode

The use utf8_func pragma replaces substr with substr_utf8.

The use bytes_func pragma replaces substr with substr_bytes.

Feel free to comment.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .