文本视图显示了阿拉伯语字符作为问号" ?????" [英] Text view displays Arabic characters as question marks "?????"

查看:2536
本文介绍了文本视图显示了阿拉伯语字符作为问号" ?????"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个Android应用程序显示一个 textviews 混合阿拉伯语和英语单词;

这是我的Java类中写为问号应用显示了阿拉伯语的文字?????这里是一个截图:

的code:

 如果(tCat.equals(StandardT _)){
     服务热线=操作/خدماتعامة
 }
tv.setText(服务热线);

我曾尝试:


  1. 解码的Andr​​oid 字符
    没有它不是同样的问题,答案没有帮助。


  2. <一个href=\"http://stackoverflow.com/questions/7962704/how-to-support-arabic-text-in-android/7962813#7962813\">How支持阿拉伯文字在Android中?
    我使用的是支持阿拉伯语一个新版本,我也试过了答案,如添加波斯语类或使用 ArabicUtilities 班但没有工作醚


  3. 我也试图EN code字符串为UTF-8

    尝试{
                 服务热线= URLEn coder.en code(服务热线,UTF-8);}
            赶上(UnsupportedEncodingException五){
                           e.printStackTrace();
            }


和没有工作!

<醇开始=4>
  • 同样使用多种字体,但不是一个单一的字样解决了这个问题试过了。

  • 所以我有点坚持在这里,任何想法?

    编辑:
    我关闭了Android的工作室,并重新打开应用程序的一切,我的Java类里面写的文字后转身问号!即使我试着写一遍吧,一旦我关闭项目并重新打开它,它显示了阿拉伯文字作为Java类中的问号连我运行应用程序之前,这实在是尴尬!


    解决方案

    您需要设置文件的文件编码包含阿拉伯文文本为 UTF-8

    这是你如何从里面更改文件编码的 Android的工作室

    I'm working on an android app that displays a textviews with mixed Arabic and English words;

    the app displays Arabic text that I wrote inside Java classes as question marks ????? here is a screenshot:

    The Code:

    if(tCat.equals("StandardT_")){
         serviceLine="Operations / خدمات عامة";
     }
    tv.setText(serviceLine);
    

    what I have tried:

    1. Decoding characters in android and no its not the same question and the answers didn't help.

    2. How to support Arabic text in Android? I'm using a new version that supports Arabic and I also tried the answer like adding Farsi Class or using ArabicUtilities classes but that didn't work ether

    3. I also tried to encode String into utf-8

      try { serviceLine= URLEncoder.encode(serviceLine, "utf-8");} catch(UnsupportedEncodingException e){ e.printStackTrace(); }

    and that didn't work!

    1. also tried using multiple fonts but not a single Typeface solved the problem.

    So I'm kind of stuck here, any ideas?

    Edit: After I closed android studio and reopened the app all of the text that I wrote inside the Java classes turned to question marks! Even though I tried to write it again, once I closed the project and reopened it, it displays the Arabic text as question marks inside the Java classes before even I run the application and this is really awkward!

    解决方案

    You need to set the file encoding of the file that contains the arabic text to UTF-8.

    This is how you change file encoding from inside Android-Studio.

    这篇关于文本视图显示了阿拉伯语字符作为问号&QUOT; ?????&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆