某些阿拉伯文字显示不正确,而其他阿拉伯文字显示正常? [英] Certain Arabic text gets incorrectly shown while other Arabic text gets showed normally?
问题描述
我正在开发一个带有阿拉伯语文本的应用程序..我的手机支持阿拉伯语,所以文本可以正确显示..奇怪的问题是:如果我从 a.txt 文件中复制我想要的阿拉伯语文本并放入将它转换为 EditText,EditText 显示奇怪的字符,但如果我手动编写相同的文本(不是复制粘贴),文本将正常显示!!
这是我的意思的图片,第一个 EditText 是我手动编写的文本,第二个是我从 .txt 文件中复制粘贴的文本..
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..
这是应用程序的代码:
Here is the code of the app:
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>
我希望你明白我的意思,因为要解释这个奇怪(愚蠢)的问题并不容易.谢谢.
I hope you get what I mean, since it wasnt easy to explain this weird (stupid) problem. Thanks.
推荐答案
如果你把 setText 排成一行,第二个比第一个长,这意味着它几乎肯定包含看起来像空格但实际上是其他东西的字符;尝试对字符串进行 UTF-8 编码并逐块比较.
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.
这篇关于某些阿拉伯文字显示不正确,而其他阿拉伯文字显示正常?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!