Cwd::utf8(3)
π Cwd::utf8 π
okay bestie so this is the Cwd::utf8 page from the User Contributed Perl Documentation, and it's literally the glow-up your file paths have been begging for. sit down, grab a boba, we're doing utf-8 β¨
β¨ VERSION β¨
version 0.014 β she's on 0.014, no cap π
πΈ SYNOPSIS πΈ
# Using the utf-8 versions of cwd, getcwd, fastcwd, fastgetcwd
use Cwd::utf8;
my $dir = getcwd;
# Using the utf-8 versions of abs_path
use Cwd::utf8 qw(abs_path);
my $abs_path = abs_path($file);
# Exporting no functions
use Cwd::utf8 qw(:none); # NOT "use Cwd::utf8 qw();"!
my $real_path = Cwd::real_path($file);
likeβ¦ look at her. three little modes. pick your fighter π
π¦ DESCRIPTION π¦
So here's the tea: the OG Cwd functions are actually pretty decent at handling UTF-8, right? but they expect and return everything as bytes, not as characters. and that's the difference between "yeah it works" and "it works and I'm not crying" π
This module swaps out all the Cwd functions for fully UTF-8 aware versions β they both expect and return characters. it's giving main character energy for your paths π
Note: the function replacement does NOT happen on DOS, Windows, and OS/2, because those systems don't have full UTF-8 file system support. not her fault, she's just being honest π
π Behaviour π
This module behaves like a pragma, which is the cute part β you can flip it on and off with use Cwd::utf8 and no Cwd::utf8. turn utf-8 support on, turn it off, on, off. self-care π§
By default, cwd(), getcwd(), fastcwd(), and fastgetcwd() are exported β same as the original Cwd β plus getdcwd() on Win32. don't want all that? just do use Cwd::utf8 qw(:none) and she'll keep her hands to herself π«Ά
Also, important: because all the magic lives inside the module'simportfunction, you literally cannot just douse Cwd::utf8 qw(). that's not a thing. useqw(:none), bestie. iykyk π
π ATTRIBUTES π
$Cwd::utf8::UTF8_CHECK
By default, Cwd:::utf8 treats decoding errors as FATAL β the default value for this setting is Encode::FB_CROAK. so yeah, she does not play about decode errors π
but if you're built different, you can change it by setting Cwd::utf8::UTF8_CHECK:
Encode::FB_WARNβ reports the encoding errors as warnings instead of dying. gentle. communicative. mature.Encode::FB_DEFAULTβ completely ignores them. head in the sand. we respect the choice, honestly π
see Encode for the details on all of this β¨
Note: Encode::LEAVE_SRC is always enforced. non-negotiable. periodt. π
π BUGS π
please report any bugs or feature requests on the bugtracker website:
https://github.com/HayoBaan/Cwd-utf8/issues
and when you do submit a bug or a request, pls pls pls include a test-file or a patch to an existing test-file that shows off the bug or the desired feature. receipts, bestie. bring receipts π§Ύ
πΈ COMPATIBILITY πΈ
The filesystems of Dos, Windows, and OS/2 do not (fully) support UTF-8. so the Cwd function will not be replaced on these systems. she's not being rude, she's just being real π
π SEE ALSO π
Cwdβ The original module π«‘File::Find::utf8β Fully utf-8 aware versions of theFile::Findfunctions πutf8::allβ Turn on utf-8, all of it. This was also the module I first added the utf-8 aware versions ofCwdandFile::Findto before moving them to their own package π
π AUTHOR π
Hayo Baan <info@hayobaan.com>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2014 by Hayo Baan.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page, babe π this was perl v5.42.0, dated 2026-01-21, and it lives at Cwd::utf8(3) β go forth and have the most character-encoded paths of your life, ily, mwah π«Άβ¨π
π¦ where this page comes from
- fedora 43: perl-Cwd-utf8 0.014-1.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- fedora 44: perl-Cwd-utf8 0.014-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms