CheckUTF8(3)
πΈ NAME πΈ
So bestie, you know what this is? It's Unicode::CheckUTF8 β literally the vibe check for your scalars, checking if they're valid UTF-8. Periodt. π
This page is coming at you from the User Contributed Perl Documentation corner of the universe, and it's about to be your new fave. π«Ά
β¨ SYNOPSIS β¨
Okay so here's the whole entire mood:
use Unicode::CheckUTF8 qw(is_utf8);
my $is_ok = is_utf8($scalar);
That's it. That's the whole slay. You import is_utf8, you feed it a scalar, it tells you if it's valid. Iconic behavior, no cap. π
π DESCRIPTION π
Alright bestie, let me put you on. This module is an XS wrapper around some Unicode Consortium code β you know, the official Unicode people, the main characters of text encoding β and what it does is check if a string is valid UTF-8. π¦
But wait, there's more! It's been revised to conform to what expat/Mozilla think is valid UTF-8 β especially when it comes to low-ASCII characters. So it's not just regular valid, it's their kind of valid. It's giving β¨collaborationβ¨.
Not me needing to say this, but: this module has NOTHING to do with Perl's internal UTF8 flag on scalars. Like, zero. Zilch. Nada. Please don't confuse them, I'm begging. π
So when do you use this? Literally whenever you're getting input from users and you want to make sure it's valid UTF-8 before you keep going. You know how users are β they'll send you the wildest byte sequences and just expect you to deal. This module is your bouncer. It checks IDs at the door. πͺπ
π HISTORY π
Okay so storytime, gather 'round. π―οΈ
This is some old code, bestie. Like, dating back to before Perl 5.8 and before Unicode support even existed in Perl. We're talking ancient. Y2K-era ancient. The way this code has seen things. π
And the author is like, "I wish I didn't have to keep using this code" β honestly same energy as me still using the same password since 2016 π β but they literally can't find any other code on CPAN for UTF-8 checking that's both sufficiently fast and, more importantly, correct. So now there's yet another way to do it. The C in CPAN stands for "Can't Please Anyone" and this module is living proof. π
π BUGS π
Hopefully not, but mail me if so! π§
That's it. That's the whole bugs section. The confidence. The audacity. The main character energy. We love a humble king who assumes his code is flawless. π₯
π AUTHOR π
Let's give credit where credit is due, besties! π
- Brad Fitzpatrick
<brad@danga.com>β based on Unicode Consortium code. The OG. The architect. The one who said "fine, I'll do it myself." β - Artur Bergman β helped kill old Inline code using his awesome knowledge of all things Perl and XS. We stan a collaborative king. π§
And that's the whole page, babes! π
This masterpiece of documentation was brought to you by perl v5.32.1 on 2019-10-29 β so if you're reading this, just know that the vibes are timeless and the UTF-8 checking is eternal. Slay! πβ¨ππ¦πΈπ
π«Άππ₯ππβππππ§π
π¦ where this page comes from
- epel 9: perl-Unicode-CheckUTF8 1.03-27.el9 Β· UCD and (GPL+ or Artistic)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms