java id3v2_解决方法java - how to decode ID3V2 tag fetched using jid3lib-0.5.4

[官方详细介绍官方文档里有个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]

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值