2011-04-27 4 views
2

아랍어 텍스트가있는 앱을 개발 중입니다. 내 전화가 아랍어를 지원하므로 텍스트가 올바르게 표시됩니다. 이상한 문제는 다음과 같습니다. a.txt 파일에서 원하는 아랍어 텍스트를 복사하여 넣으면 EditText에 EditText는 이상한 문자를 표시하지만 수동으로 (복사하여 붙여 넣기가 아닌) 같은 텍스트를 쓰면 텍스트가 정상적으로 표시됩니다 !!
여기 무슨 뜻인지 보여주는 사진입니다, 여기에 enter image description here다른 아랍어 텍스트가 정상적으로 표시되는 동안 특정 아랍어 텍스트가 잘못 표시됩니까?


이의 코드입니다 .. 처음 글고 내가 직접 쓴 텍스트이고, 두 번째는 내가 복사 - 붙여 넣기 텍스트 .txt 파일에서입니다 응용 프로그램 :
enter image description here

XML 파일 :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" android:orientation="vertical"> 
    <EditText android:text="EditText" android:id="@+id/editText1" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText> 
    <EditText android:text="EditText" android:id="@+id/editText2" android:layout_width="wrap_content" android:layout_height="wrap_content"></EditText> 
</LinearLayout> 

나는 그것이 이상한 (바보 같은) 문제를 설명하기 쉬운 않네 때문에 당신이 무슨 뜻인지 얻을 수 있기를 바랍니다. 감사.

+0

[이 링크에있는] 솔루션 (http://stackoverflow.com/a/7962813/779408)을 찾을 수 있습니다. 즐겨! :) – breceivemail

답변

0

setText를 위로 줄 경우 두 번째 문자는 첫 번째 문자보다 길어 지므로 공백 문자처럼 보이지만 실제로는 다른 문자가 포함됩니다. UTF-8 문자열을 인코딩하고 블록 단위로 비교해보십시오.

+0

나는 문자 배열로 변환, 그리고 이상한 값이있었습니다 .. 그들은 이상한 문자의 원인이었다. 감사합니다. – Omar

+0

[이 링크에있는] 솔루션을 찾을 수 있습니다 (http://stackoverflow.com/a/7962813/779408). 즐겨! :) – breceivemail

+0

이상한 문자는 아마도 마이크로 소프트 때문에 유니 코드 [바이트 순서 표시, BOM] (http://en.wikipedia.org/wiki/Byte_order_mark) 일 수 있습니다. – hippietrail

관련 문제