我在這個路徑名中如何獲得這樣一種奇怪的編碼?
在我的文件管理器(Dolphin)中,路徑名看起來不錯。關於路徑名編碼的問題
#!/usr/local/bin/perl
use warnings;
use 5.014;
use utf8;
use open qw(:encoding(UTF-8) :std);
use File::Find;
use Devel::Peek;
use Encode qw(decode);
my $string;
find(sub { $string = $File::Find::name }, 'Delibes, Léo');
$string =~ s|Delibes,\ ||;
$string =~ s|\..*\z||;
my ($s1, $s2) = split m|/|, $string, 2;
say Dump $s1;
say Dump $s2;
# SV = PV(0x824b50) at 0x9346d8
# REFCNT = 1
# FLAGS = (PADMY,POK,pPOK,UTF8)
# PV = 0x93da30 "L\303\251o"\0 [UTF8 "L\x{e9}o"]
# CUR = 4
# LEN = 16
# SV = PV(0x7a7150) at 0x934c30
# REFCNT = 1
# FLAGS = (PADMY,POK,pPOK,UTF8)
# PV = 0x7781e0 "Lakm\303\203\302\251"\0 [UTF8 "Lakm\x{c3}\x{a9}"]
# CUR = 8
# LEN = 16
say $s1;
say $s2;
# Léo
# Lakmé
$s1 = decode('utf-8', $s1);
$s2 = decode('utf-8', $s2);
say $s1;
say $s2;
# L�o
# Lakmé
像文件測試運算符一樣使用解碼或編碼文件名稱的'-f'? –
文件測試運算符也需要八位字節 – moritz