While the id3 tags contain non-ascii characters, the
following exception is thrown:
<pre>
java.lang.StringIndexOutOfBoundsException: String
index out of range: 33
at java.lang.String.substring(Unknown Source)
at helliker.id3.ID3v1Tag.chopSubstring
(ID3v1Tag.java:199)
at helliker.id3.ID3v1Tag.readTag
(ID3v1Tag.java:163)
at helliker.id3.ID3v1Tag.<init>
(ID3v1Tag.java:102)
at helliker.id3.MP3File.<init>
(MP3File.java:180)
at helliker.id3.MP3File.<init>
(MP3File.java:132)
...
</pre>
After inspecting the the ID3v1Tag, the problem can be
solved by this change in the <code>readTag</code> call.
<pre><code>
...
raf.seek( raf.length() - TAG_SIZE );
byte[] buf = new byte[TAG_SIZE];
raf.read( buf, 0, TAG_SIZE );
//** Remove the tag string, we use the buf directly
//String tag = new String( buf, 0, TAG_SIZE);
//**/
//** Instead of calling chopSubstring, we initialize
//** new Strings directly for each tag
//title = chopSubstring( tag, start, start +=
TITLE_SIZE );
//artist = chopSubstring( tag, start, start +=
ARTIST_SIZE );
//album = chopSubstring( tag, start, start +=
ALBUM_SIZE );
//year = chopSubstring( tag, start, start +=
YEAR_SIZE );
//comment = chopSubstring( tag, start, start +=
COMMENT_SIZE );
//***/
int start = TAG_START.length();
title = new String(buf, start, TITLE_SIZE);
artist = new String(buf, start+=TITLE_SIZE,
ARTIST_SIZE);
album = new String(buf, start+=ARTIST_SIZE,
ALBUM_SIZE);
year = new String(buf, start+=ALBUM_SIZE, YEAR_SIZE);
comment = new String(buf, start+=YEAR_SIZE,
COMMENT_SIZE);
</code></pre>
Tested with my non-english songs, look fine..
Modified ID3v1Tag source file
Modified ID3v2Frame source file
Logged In: YES
user_id=445393
Similar changes can be made in ID3v2Frame::getDecodedString
such that the non-ascii characters can be extracted
correctly in ID3v2 Tag as well.
Modified ID3v1Tag, IDv2Tag, IDv2Frame and MP3File which support character encoding
Logged In: YES
user_id=445393
Added some more changes to IDv1Tag, IDv2Tag, IDv2Frame and
MP3File. Add extra get/set functions that support
character encoding.