Concatinating阿拉伯文和英文文本TextView的机器人 [英] Concatinating Arabic and English text android TextView

查看:427
本文介绍了Concatinating阿拉伯文和英文文本TextView的机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的算法,能够串联阿拉伯文字和英文文本

I have the following algorithm to be able to concatenate Arabic text and English text

private String getFormatedArabicEnglishMessage (String [] parts) {

    String retString = "";

    for (int i = 0; i < parts.length; i++) {

        if (MyServices2Utils.isProbablyArabic(parts[i]) == true) {
            retString += "\u202B" + new String(" ") + "\u202C";
            retString += "\u202B" + new String(parts[i].getBytes()) + "\u202C";
            retString += "\u202B" + new String(" ") + "\u202C";
        } else {
            retString += " ";
            retString += parts[i];
            retString += " ";
        }   
    }

    return retString;
}

但不是在所有情况下工作:

but is is not working in all cases :

在默认语言环境的情况下== AR我得到的结果如下:

in case of default locale == ar I got the following results :

在默认语言环境的情况下==恩,我得到了以下结果:

in case of default locale == en I got the following results :

推荐答案

如果我的理解是正确的,你的问题是,每当区域设置不是阿拉伯语,append方法将文本添加到右侧而不是左侧,这是阿拉伯书写的文本(从右到左)的方式。

If I understood it right, your problem is that whenever the Locale is not arabic, the append method adds text to the right instead of to the left, which is the way of writing arabic texts (from right to left).

如果这是问题,你必须检查区域设置,如果它不是阿拉伯语,你需要这个属性设置为的TextView 或你使用什么:

If this is the issue, you'll have to check for the Locale and if it's not arabic, you'll need to set this property to the TextView or whatever you're using:

android:textDirection="anyRtl"

请参阅获取更多信息。

这篇关于Concatinating阿拉伯文和英文文本TextView的机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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