Subject: | Setting MP3TAG_DECODE_UTF8=0 doesn't work |
Using the following code snippet:
BEGIN {
# We expect utf-8 encoded filesystem names, so tell MP3::Tag not to
# decode the tags.
$ENV{MP3TAG_DECODE_UTF8} = 0;
}
I expect to be able to see utf8 strings, but instead see latin1 strings
because Encode::encode('UTF-8', $found) is never called.
I think the attached patch is correct - $encoding in my case is set to
zero (the _encoding tag is read with a value of zero) but I wouldn't
really expect that to stop the code from doing the UTF-8 encoding.
If you have a better fix in mind but no time to implement it, I'm happy
to do the work.
Other details:
I have LC_ALL=en_US.UTF-8.
I use MP3::Tag to verify v1 tags against v2 tags against filesystem
details under FreeBSD to keep my music collection tagged consistently.
With the attached patch I can compare names such as Sinéad
O'Connor/Sean-Nós Nua/10 Báidín Fheilimí.mp3 with the tags contained in
the file.
Cheers.
Subject: | patch-ID3v2.pm |
--- Tag/ID3v2.pm.orig 2008-01-30 01:41:48.000000000 -0800
+++ Tag/ID3v2.pm 2008-01-30 02:52:17.000000000 -0800
@@ -1773,7 +1773,7 @@
my ($self, $data, $format) = @_;
my ($rule, $found,$encoding, $result, $e);
- $encoding=0;
+ $encoding=$result->{encoding};
foreach $rule (@$format) {
next if exists $rule->{v3name};
# get the data
@@ -1808,10 +1808,10 @@
# decode data
warn "Encoding type '$encoding' not supported: found in $rule->{name}\n";
next;
- } elsif ($encoding and not $trustencoding) {
+ } elsif (defined $encoding and not $trustencoding) {
warn "UTF encoding types disabled via MP3TAG_DECODE_UNICODE): found in $rule->{name}\n";
next;
- } elsif ($encoding) {
+ } elsif (defined $encoding) {
# 0 = latin1 (effectively: unknown)
# 1 = UTF-16 with BOM
# 2 = UTF-16be, no BOM