Android的2.X梵文UNI code问题 [英] Android 2.x devanagari unicode issue

查看:141
本文介绍了Android的2.X梵文UNI code问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解Android 2.x的梵文字体支持(即使Android 2.x是不能够呈现梵文字体),使用以下code。在code做工精致,除了具有raswa'和'dirga的一些问题。是否有可能获得的Andr​​oid 2.X正确的梵文重新presentation?

I am trying to support for devanagari font for android 2.x (even though android 2.x is not capable of rendering the devanagari font) using following code. The code is working fine except having some issues with 'raswa' and 'dirga'. Is it possible to obtain the correct devanagari representation in android 2.x ?

Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/mangal.ttf");
TextView txtviewword=(TextView) findViewById(R.id.textViewWord);
txtviewword.setTypeface(typeface);

这是不正确重新presentation(从安卓2.3):

This is incorrect representation(from android 2.3):

这应该是比较喜欢这样(从Android 4.4系统):

This should have been rather like this(from android 4.4):

推荐答案

在问题分析我的情况后,我发现换raswa'的位置与字母('AKSHAR')本身将解决姜饼问题。于是,我换'raswa和字母的位置。所以,这提供了问题的解决方法。

After analysing my situation over the problem, I found that swapping the position of 'raswa' with the alphabet ('akshar') itself would solve the problem for gingerbread. So, I swapped the position of 'raswa' and alphabet. So, this provided the problem workaround.

if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
   char[] array = content[1].toCharArray();   /*content[1] is a string containing the original version */
   for(int i=0; i<array.length; i++){
        char c = array[i];
        int code = (int) c;
        if (code == 2367){    //2367 is int value for 'raswa'
            char temp = array[i-1];
            array[i-1]=c;
            array[i]=temp;
        }
    }
    String str = String.copyValueOf(array); /*This string contains the swapped version(symantically its wrong, though. It's works as my solution.)*/
    Log.d("DetailActivity", "from gingerbread");
    Log.d("DetailActivity", str);
    if(!content[1].equals(null))txtviewdevanagari.setText(str);
}else{
    Log.d("DetailActivity", "from ICS+");
    if(!content[1].equals(null))txtviewdevanagari.setText(content[1]);
}

这篇关于Android的2.X梵文UNI code问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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