[官方详细介绍官方文档里有个bug追查代码才发现的isVirtualWebappRelative - Should \"virtual\" SSI directivepaths be interpreted as relative to th]
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java. But I am getting messy strings. Here is my code:
import org.farng.mp3.MP3File;
import org.farng.mp3.id3.AbstractID3v2;
public class NewClass {
public static void main(String [] args){
try{
MP3File file = new MP3File("c:\\2.mp3");
AbstractID3v2 tag = file.getID3v2Tag();
String str = tag.getAuthorComposer();
System.out.println("Lenght: "+str.length());
for(int i = 0; i < str.length(); i++){
char ch = str.charAt(i);
System.out.println(i+": "+"'"+(ch)+"' : "+((int)ch));
}
System.out.println(str);
}catch(Exception e){
e.printStackTrace();
}
}
}
And I am getting following output:
Lenght: 35
0: '�' : 65533
1: '�' : 65533
2: 'H' : 72
3: ' ' : 0
4: 'i' : 105
5: ' ' : 0
6: 'm' : 109
7: ' ' : 0
8: 'e' : 101
9: ' ' : 0
10: 's' : 115
11: ' ' : 0
12: 'h' : 104
13: ' ' : 0
14: ' ' : 32
15: ' ' : 0
16: 'R' : 82
17: ' ' : 0
18: 'e' : 101
19: ' ' : 0
20: 's' : 115
21: ' ' : 0
22: 'h' : 104
23: ' ' : 0
24: 'a' : 97
25: ' ' : 0
26: 'm' : 109
27: ' ' : 0
28: 'm' : 109
29: ' ' : 0
30: 'i' : 105
31: ' ' : 0
32: 'y' : 121
33: ' ' : 0
34: 'a' : 97
��H i m e s h R e s h a m m i y a
But in Windows Explorer it shows correct "Himesh Reshammiya".
How can I get this correct String in java, or any solution to decode this string?
I think this may be some character encoding. Thanks in advance
java
character-encoding
id3v2
|
this question asked Jan 13 '13 at 9:01
UDPLover 2,272 3 19 49
|
4 Answers
4
异常解决方法
I'll hazard a guess that the library doesn't support UTF-16 encoded text, which that appears to be (The first two characters listed in the output are the BOM).
You should probably use one of the libraries listed here: http://id3.org/Implementations
Looking through the Java ones, this could be a good one: https://github.com/mpatric/mp3agic
It says it supports Unicode right on the page.[官方详细介绍官方文档里有个bug追查代码才发现的isVirtualWebappRelative - Should \"virtual\" SSI directivepaths be interpreted as relative to th]
|
this answer answered Jan 13 '13 at 9:23
Matt Sieker 5,080 2 18 33
|
Possible workaround:
replaceAll("\\s","")
This removes all whitespaces and non-visible characters.
|
this answer answered Jan 13 '13 at 9:23
Kurt Du Bois 5,234 3 15 30 Doesn't remove NUL or unicode replacement character, just white space. –
Esailija Jan 13 '13 at 11:08
|
3: ' ' : 0 your problem is this as i see?
just put this ' ' char (which is no space) in a new Integer() and it must be equals 0.
|
this answer answered Oct 9 '13 at 13:13
hec 1
|
|
this answer answered Oct 19 '13 at 12:31
Abhishek Dhankar 1
|
[本文转http://googledave.javaeye.com/blog/438474ssi直译server side include ,服务器端包括关键字: tomcat ssi shtm]