/ / Lectura de un archivo de texto árabe de una carpeta sin procesar en Android - Android, árabe

Leyendo el archivo de texto en árabe de una carpeta sin formato en Android - Android, árabe

Necesito leer el texto árabe almacenado en el archivo en la carpeta sin procesar y mostrar el texto en la vista de texto. Cuando trato de hacerlo, recibo un texto extraño.

Respuestas

0 para la respuesta № 1

Primero debe usar una fuente externa y agregarla a la carpeta de evaluación.

TextView txtView;
Typeface arabicFont;

txtView= (TextView)findViewById(R.id.arabicTextDisplayTextView);
arabicFont =Typeface.createFromAsset(getAssets(),"arabic_fonttf");
txtView.setTypeface(arabicFont);
txtView.setTextSize(20);

InputStream is = getResources().openRawResource(R.raw.arabic_text);
BufferedInputStream bis = new BufferedInputStream(is);
int myInt=0;

try{
ByteArrayBuffer myByteArray = new ByteArrayBuffer(100);
while((myInt = bis.read())!=-1)
{
if(myInt == 10) break;
myByteArray.append((byte)myInt);
}

String arabicLine = new String(myByteArray.toByteArray(), 0, myByteArray.length(), "utf-8");
txtView.setText(arabicLine);