【发布时间】:2014-11-15 17:47:02
【问题描述】:
我的问题是,如果我使用字符串硬编码,答案是正确的,但如果我使用输入的字符串不起作用。 例如:
String variable = " \u0020\uFEB3\uFEE8\uFB93\u0020\uFEBB\uFE92\uFEEE\u0631\u0020";
TextView show = (TextView) findViewById(R.id.preshow);
show.settext(variable );
textview 显示:صنگ صبور
但是:
File filematn = new File(Environment.getExternalStorageDirectory()+File.separator+"SingingStudio/"+songname+"/"+songname+"file.txt");
//Read text from file
StringBuilder text = new StringBuilder();
try {
BufferedReader br = new BufferedReader(new FileReader(filematn));
String line;
while ((line = br.readLine()) != null) {
text.append(line);
text.append('\n');
}
br.close();
}
catch (IOException e) {
//You'll need to add proper error handling here
}
String variable = text.toString();
TextView show = (TextView) findViewById(R.id.preshow);
show.settext(variable );
文本视图显示:\u0020\uFEB3\uFEE8\uFB93\u0020\uFEBB\uFE92\uFEEE\u0631\u0020
我该如何解决它。谢谢你
【问题讨论】:
-
解析出来并转换成Unicode。