mpatric / mp3agic

A java library for reading mp3 files and reading / manipulating the ID3 tags (ID3v1 and ID3v2.2 through ID3v2.4).
MIT License
1.2k stars 309 forks source link

Not working with cyrillic symbols #162

Open Dilitand opened 4 years ago

Dilitand commented 4 years ago

Good day! Have problems with cyrillic symbols. I have empty results on mp3 files when i used it.

For example, you will have empty spaces on Artist and Title if u make something like this:

Mp3File mp3file = new Mp3File("SomeMp3File.mp3"); if (mp3file.hasId3v2Tag()) { id3v2Tag.setArtist("Киррилица Артист"); id3v2Tag.setTitle("Кирилица Титле"); mp3file.save("MyMp3File.mp3"); }

jmizv commented 3 years ago

Hi @Dilitand,

I've created this test method and it worked fine:

    @Test
    public void shouldWriteCyrillic() throws Exception {
        String filename = "WithCyrillic.mp3";
        String cyrillicArtist = "Киррилица Артист";
        String cyrillicTitle = "Кирилица Титле";

        try {
            Mp3File file = new Mp3File(MP3_WITH_ID3V1_AND_ID3V23_AND_CUSTOM_TAGS);
            ID3v2 id3v2Tag = file.getId3v2Tag();
            id3v2Tag.setArtist(cyrillicArtist);
            id3v2Tag.setTitle(cyrillicTitle);
            file.save(filename);

            Mp3File createdFile = new Mp3File(filename);
            assertTrue(createdFile.hasId3v2Tag());
            ID3v2 newTag = createdFile.getId3v2Tag();
            assertEquals(cyrillicArtist, newTag.getArtist());
            assertEquals(cyrillicTitle, newTag.getTitle());
        } finally {
            TestHelper.deleteFile(filename);
        }
    }

Maybe your issue has already been resolved? Best