Perl Unicode Cookbook: Fine-Tuning Unicode Warnings

℞ 2: Fine-tuning Unicode warnings

It’s easy to get Unicode wrong, especially when handling user input and dealing with multiple encodings. Perl is happy to help you detect unexpected conditions of your data. Perl is also happy to let you decide if these unexpected conditions are worth warning about.

As of v5.14, Perl distinguishes three subclasses of UTF‑8 warnings. While the utf8 lexical warning category existed prior to 5.14, you may now handle these warnings individually:

 use v5.14;                  # subwarnings unavailable any earlier
 no warnings "nonchar";      # the 66 forbidden non-characters
 no warnings "surrogate";    # UTF-16/CESU-8 nonsense
 no warnings "non_unicode";  # for codepoints over 0x10_FFFF

Previous: ℞ 1: Always Decompose and Recompose

Series Index: The Standard Preamble

Next: ℞ 3: Enable UTF-8 Literals



Something wrong with this article? Help us out by opening an issue or pull request on GitHub