Certain Arabic text gets incorrectly shown while o

2019-07-17 02:04发布

I'm developing an app with Arabic text in it.. My phone supports Arabic so the text gets displayed correctly.. the weird problem is that: if I copy an Arabic text that i want from a.txt file and put it into an EditText, the EditText displays weird characters, but if I write the SAME text manually (not copy-paste), the text gets displayed normally!!
Here is a picture showing what I mean, the first EditText is the text I wrote manually, and the second is the text I copy-pasted from the .txt file..
enter image description here

Here is the code of the app:
enter image description here

xml file:

  <?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>

I hope you get what I mean, since it wasnt easy to explain this weird (stupid) problem. Thanks.

1条回答
疯言疯语
2楼-- · 2019-07-17 02:40

If you line the setText up, the second is longer than the first, which means it almost certainly contains characters that look like spaces but are actually something else; try UTF-8 encoding the string and comparing them block by block.

查看更多
登录 后发表回答