DEV Community

Yuki Kimoto - SPVM Author
Yuki Kimoto - SPVM Author

Posted on

The only correct approach for UTF-8 strings in Perl

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.

Top comments (2)

Collapse
 
ap profile image
Aristotle Pagaltzis

So what would happen if you say neither use utf8_func nor use bytes_func?

And how is use bytes_func different from use bytes?

Collapse
 
barnesric56 profile image
RawHide81

what are the tags for French?