in reply to MP3::Tag encoding problem
Try this little experiment on the command line in the same window where you want to see the tag text displayed correctly:
If you see an inverted exclamation mark, your terminal window works with iso-8859-1. If you get a question mark instead, try this next:perl -le 'print "\xa1"'
If you now see the inverted exclamation mark, you now know that your terminal wants utf8.perl -CS -le 'print "\xa1"'
For an 8859-based display, perl should probably do nothing to the tag text before printing it. But I doubt this is the situation, because I don't think you would have been seeing "?" in your tag text if this were the case.
For a utf8-based display, it should sufficed to do binmode STDOUT, ":utf8"; which will automatically (and quietly) "upgrade" the 8859-1 text to utf8 when printing to STDOUT.
If you are storing the tag text to a file, and are seeing question marks when looking at the file contents, it's the same basic issue. Use binmode on that file handle instead of STDOUT.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: MP3::Tag encoding problem
by mfearby (Initiate) on Sep 22, 2008 at 11:16 UTC | |
Your knowledge of unicode is impressive, and I wish to subscribe to your newsletter :-) I saw the upside-down question mark for the second command, confirming that my terminal (Konsole) wants utf8. It also seems that specifying the binmode and commenting-out my misguided attempts at trying to solve the problem now means I'm seeing umlauts above my o's. Thank you very much! | [reply] |
by lbt (Initiate) on Jan 01, 2009 at 11:41 UTC | |
The module returns a character string (Dec '08); so that's OK. Make sure any applications writing the tags encode properly. For linux, Easytag seems to work very well. What you want as a human but no good for mkpath() et al ah, now this is mkpath()-able Now, File::Find (properly) returns a binary string so needs decoding. Assuming your filesystem uses utf8 encoding: At this point you can print and compare $char_file_find_dir and $tag_dir. You can also compare and do filename tests etc with $binary_tag_dir and $File::Find::dir. When printing (including debugging) I had: This tells perl that my terminal is utf8 aware and to print accented characters appropriately. You should also encode() the binary strings before printing them if you want to read them (or not if you want to 'od' them) HTH Corretcions welcome ;) | [reply] [d/l] [select] |
by jwhit61 (Initiate) on Dec 28, 2008 at 21:50 UTC | |
| [reply] |
by jwhit61 (Initiate) on Jan 03, 2009 at 14:17 UTC | |
and the following to read: The data will print correctly to STDOUT, but other programs that are reading the data, show the extended characters incorrectly. If I use easytag to manipulate the same tags after the write process above, the data is incorrect in easytag. I fix it inside of easytag and other programs like Mythmusic show the tags correctly. Also, post easytag, I remove the decode UTF8 instructions in my script and just print the data to STDOUT, the tags print correctly. The problem has to be with MP3::Tags. Here is my code. You will see that I am also writing FLAC tags when the fils has a flac extension, The same data that gives me grief for MP3 works just fine when I write to a FLAC file. I've commented out my UTF8 attempts in the MP3 code as it did not yield any difference to other applications.
| [reply] [d/l] [select] |
by jwhit61 (Initiate) on Jan 23, 2009 at 18:06 UTC | |
| [reply] [d/l] |