我做了很多试验,但无法从原始资源文本文件中读取希伯来语字母。每次我试一试,我都会得到?如果我在读英文信,一切都没问题。我也尝试使用UTF-8,但我也得到了吉比利亚语。
这是我正在使用的代码。
InputStream inStream = getResources().openRawResource(R.raw.questutf8);
if (inStream != null)
{
InputStreamReader inputReader = new InputStreamReader(inStream);
int c, i=0;
int i=0;
char [] cb = new char[1];
byte [] buf = new byte[100];
String line;
while (inputReader.read(cb, 0, 1) > -1)
{
if(cb[0] == '\r' || cb[0] == '\n')
{
line = new String(buf, 0, i, "UTF-8");
i=0;
//Doing somthing with line
}
else
{
buf[i++] = (byte) cb[0];
}
}
}有谁知道我该怎么做吗?提前感谢!
发布于 2011-10-25 02:45:50
如果源文件是UTF-8,请尝试使用InputStreamReader(InputStream, String)构造函数传入编码并读取UTF-8格式的文件:
InputStreamReader inputReader = new InputStreamReader(inStream, "UTF-8");https://stackoverflow.com/questions/7880002
复制相似问题