Getting Arabic text from .txt file?

此生再无相见时 提交于 2019-12-24 03:34:20

问题


Hey, I have Arabic text in a txt file that I would like to show in a simple EditText, Though when I do that here is what I get: http://i55.tinypic.com/66g09z.png

Here is the code I use to get the text from the .txt file:

    txt1 =(EditText) findViewById(R.id.EditText01); 

    try{

           File f = new File(Environment.getExternalStorageDirectory()+"/1.txt");
           FileInputStream fileIS = new FileInputStream(f);          
           BufferedReader buf = new BufferedReader(new InputStreamReader(fileIS));           
           String readString = new String();             

           //just reading each line
           while((readString = buf.readLine())!= null){          
               txt1.setText(txt1.getText().toString()+readString);                
           }             
        } catch (FileNotFoundException e) {

           e.printStackTrace();

        } catch (IOException e){

           e.printStackTrace();          
        }

}

How can I get proper Arabic letters into the EditText? Thanks


回答1:


What version of android do you run? Android has no support for Arabic locales up until 2.3 version. You can find more info about locales supported on corresponding SDK pages. For example, list of SDK 2.3 supported locales is here.




回答2:


You need to make sure that a font with Arabic characters is installed, and set the font of the EditText to it. The former is the annoying part. (I think I made SwiftKey do it for me by telling it to download the appropriate language modules.)



来源:https://stackoverflow.com/questions/5403615/getting-arabic-text-from-txt-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!