mp3agic icon indicating copy to clipboard operation
mp3agic copied to clipboard

Reading Chinese encoded tags seems to sometimes have problems.

Open joe-vettek opened this issue 2 years ago • 1 comments

my code is like this:

                mp3file.save(basePath + tt);
                id3v22Tag.setEncoder("2");
                mp3file.setId3v2Tag(id3v22Tag);
                id3v22Tag = mp3file.getId3v2Tag();
                if (id3v22Tag.getAlbum() != null && !id3v22Tag.getAlbum().isEmpty()) 
                    this.album = id3v22Tag.getAlbum();

I've tried tweaking the encoder to salvage the bad encoding, but it doesn't seem to work. The library outputs UTF-8 encoding by default, while Chinese encoding is sometimes GBK. But the result always shows like this: OutPut: ×÷´Ê£ºFinale ×÷Çú/±àÇú/Ñݳª£ººÓͼ Actually: 2008作词:Finale 作曲/编曲/演唱: The setEncoder function doesn't seem to do anything.

joe-vettek avatar Sep 08 '22 09:09 joe-vettek

Ok, I found a simple way to solve it. Just check the encoder of the output, and then convert it into the encoder you want.

Log.d(TAG, "alertMp3Info: "+ SimpleTool.getEncoding(id3v22Tag.getAlbum())+id3v22Tag.getAlbum());
Log.d(TAG, "alertMp3Info: "+ new String(id3v22Tag.getAlbum().getBytes("ISO-8859-1"),"gbk"));

SimpleTool.getEncoding is a method to determine which encoding it is. It depends on what language you are.

refer: https://community.mp3tag.de/t/convert-charset-encoding/14360

joe-vettek avatar Sep 09 '22 09:09 joe-vettek