leosongwei / mutagen

Automatically exported from code.google.com/p/mutagen
GNU General Public License v2.0
0 stars 0 forks source link

Unicode support when *reading* tags #28

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This may or may not be a bug. I'd ask first on a mailing list or a forum,
but I can't find one :/

I have a file which has it's tags stored as UTF16 (encoding=1, at least
that's what mutagen tells me). I open the file as follows:

meta = File( localpath )
title = meta.get( 'TIT2' ).text[0]

This will return a python unicode object. Which (AFAIK) is stored
internally as UCS2 or UCS4 (depending on compile options). So if I want the
data in UTF8, all I should need to do is:

title.encode("utf8")

This works without throwing an exception, but the string I get is not at
all what is stored in the ID3 tag. Instead I get a result with plenty of
Chinese characters and whatnot.

Any ideas what that might be?

Original issue reported on code.google.com by exh...@gmail.com on 26 Sep 2009 at 3:01

GoogleCodeExporter commented 9 years ago
Here's what I get from mutagen-inspect (other tagging tools display it 
correctly):

-- /mp3s/Alice In Chains/Alice in Chains/01 - Grind.mp3
- MPEG 1 layer 3, 192000 bps, 44100 Hz, 288.23 seconds (audio/mp3)
TDRC=1995
TALB=�䄀氀椀挀攀 椀渀 䌀栀愀椀渀猀
COMM=='eng'=YEAR: 1995
COMM=ID3v1 Comment='XXX'=YEAR: 1995
TRCK=1
TPE1=Alice in Chains
TIT2=�䜀爀椀渀搀
TCON=�䜀爀甀渀最攀

Original comment by exh...@gmail.com on 27 Sep 2009 at 10:04

GoogleCodeExporter commented 9 years ago
You need to change the encoding attribute on the frame, not just re-encode the 
text
to a different string format. I'm not really sure what you did. You should ask 
on the
QL development list. Probably the frame is not actually UCS-2, and is UTF-8 
with an
invalid encoding marker in the first place (and then, probably because you 
tagged in
Mutagen and then decided to go off and use EasyTag or something after that).

Original comment by joe.wreschnig@gmail.com on 28 Sep 2009 at 4:36

GoogleCodeExporter commented 9 years ago

Original comment by joe.wreschnig@gmail.com on 28 Sep 2009 at 4:36