MarsAndroidMp3乱码心得篇
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
乱码心得篇:
一、//就是小小的如下一条代码即可,因为Android默认的是”UTF-8“,我要把之改成”GBK“就成
InputStreamReader inputReader = new InputStreamReader(inputStream,"GBK");
二、/*在解决乱码的时候没有成功的一种方法,但是个人觉得这种方法很好,希望以后可以用得上
public static String FormatStr(String str) {
if (str == null || str.length() == 0) {
return "";
} else {
try {
str = new String(str.getBytes("ISO-8859-1"), "GBK");
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
}*/
三、中文歌名无法下载的时候:(只可以下载a1.mp3而下载不了“王者之路.mp3”的时候)
try {
String
utfMp3Name=URLEncoder.encode(mp3Info.getMp3Name(),"utf-8" );
String
utfLrcName=URLEncoder.encode(mp3Info.getMp3Name(),"utf-8" );
String mp3Url = AppConstant.URL.BASE_URL+ utfMp3Name;
String lrcUrl = AppConstant.URL.BASE_URL+ utfLrcName;
HttpDownloader httpDownloader = new
HttpDownloader();
int mp3Result = httpDownloader.downFile(mp3Url, "mp3/", mp3Info.getMp3Name());
int lrcResult = httpDownloader.downFile(lrcUrl, "mp3/", mp3Info.getLrcName());
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}。