Unicode support for android

前端 未结 7 794
春和景丽
春和景丽 2020-12-08 22:43

I am new in android. I want to know does android support Unicode. If yes, then how can we use it through java code. I have written a program

TextView tv = ne         


        
相关标签:
7条回答
  • 2020-12-08 22:59

    Create a Layout name as list.xml in Layout

    <?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="10dp"
        android:textSize="20sp" >
    </TextView>
    

    Add a TextView and a ListView in your activity_main.xml

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Large Text"
        android:id="@+id/textView" />
    <ListView
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:id="@+id/listView" />
    

    MainActivity.java

    public class MainActivity extends AppCompatActivity {        
        ListView listView;
        TextView textView;
    
        static final String[] BANGLA = new String[] {
                "Barguna District (বরগুনা)",
                "Barisal District (বরিশাল)",
                "Bhola District (ভোলা)",
                "Jhalokati District (ঝালকাঠি)",
                "Patuakhali District (পটুয়াখালী)",
                "Pirojpur District (পিরোজপুর)",
                "Bandarban District (বান্দরবান)",
                "Brahmanbaria District (ব্রাহ্মণবাড়ীয়া)",
                "Chandpur District (চাঁদপুর)",
                "Chittagong District (চট্টগ্রাম)",
                "Comilla District (কুমিল্লা)",
                "Cox's Bazar District (কক্সবাজার)",
                "Feni District (ফেনী)",
                "Khagrachhari District (খাগড়াছড়ি)",
                "Lakshmipur District (লক্ষ্মীপুর)",
                "Noakhali District (নোয়াখালী)",
                "Rangamati District (রাঙ্গামাটি)",
                "Dhaka District (ঢাকা)",
                "Faridpur District (ফরিদপুর)",
                "Gazipur District (গাজীপুর)",
                "Gopalganj District (গোপালগঞ্জ)",
                "Kishoreganj District (কিশোরগঞ্জ)",
                "Madaripur District (মাদারীপুর)",
                "Manikganj District (মানিকগঞ্জ)",
                "Munshiganj District (মুন্সীগঞ্জ)",
                "Narayanganj District (নারায়ণগঞ্জ)",
                "Narsingdi District (নরসিংদী)",
                "Rajbari District (রাজবাড়ী)",
                "Shariatpur District (শরীয়তপুর)",
                "Tangail District (টাঙ্গাইল)",
                "Bagerhat District (বাগেরহাট)",
                "Chuadanga District (চুয়াডাঙ্গা)",
                "Jessore District (যশোর)",
                "Jhenaidah District (ঝিনাইদহ)",
                "Khulna District (খুলনা)",
                "Kushtia District (কুষ্টিয়া)",
                "Magura District (মাগুরা)",
                "Meherpur District (মেহেরপুর)",
                "Narail District (নড়াইল)",
                "Satkhira District (সাতক্ষিরা)",
                "Jamalpur District (জামালপুর)",
                "Mymensingh District (ময়মনসিংহ)",
                "Netrakona District (নেত্রকোনা)",
                "Sherpur District (শেরপুর)",
                "Bogra District (বগুড়া)",
                "Joypurhat District (জয়পুরহাট)",
                "Naogaon District (নওগাঁ)",
                "Natore District (নাটোর)",
                "Chapainawabganj District (নওয়াবগঞ্জ)",
                "Pabna District (পাবনা)",
                "Rajshahi District (রাজশাহী)",
                "Sirajgonj District (সিরাজগঞ্জ)",
                "Dinajpur District (দিনাজপুর)",
                "Gaibandha District (গাইবান্ধা)",
                "Kurigram District (কুড়িগ্রাম)",
                "Lalmonirhat District (লালমনিরহাট)",
                "Nilphamari District (নীলফামারী)",
                "Panchagarh District (পঞ্চগড়)",
                "Rangpur District (রংপুর)",
                "Thakurgaon District (ঠাকুরগাঁও)",
                "Habiganj District (হবিগঞ্জ)",
                "Moulvibazar District (মৌলভীবাজার)",
                "Sunamganj District (সুনামগঞ্জ)",
                "Sylhet District (সিলেট)"
        };
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
            setSupportActionBar(toolbar);
            textView= (TextView)findViewById(R.id.textView);
            textView.setText(Html.fromHtml("বাংলাদেশের জেলা সমূহ"));
            edittext = (EditText)findViewById(R.id.editText);
            imageView= (ImageView)findViewById(R.id.imageView);
    
            listView=(ListView)findViewById(R.id.listView);
    
            listView.setAdapter(new ArrayAdapter<String>(this,R.layout.list, BANGLA));
    
       }
    }
    

    Hope this will Help you...

    0 讨论(0)
  • 2020-12-08 23:01

    "Supporting Unicode" - which is simply a character encoding standard - and displaying Unicode text in a way that can be read properly are whole different things.

    The latter requires both a proper font for the script concerned and a complex text rendering engine which applies rules embedded in the font to display text properly. In Windows this is handled by system library called Uniscribe, on Apple systems by ATSUI, and on Linux systems by Pango. Android is based on Linux but unfortunately Google seem to have removed the parts for handling complex scripts. (A rather strange decision since most Android devices are for communications including text.) Complex scripts work fine on other mobile devices using a Linux based operating system like the Nokia N9 and N900

    Android also makes it difficult for users to install additional fonts or keyboard layouts that can be used by different applications without "rooting" their phone or tablet.

    A few manufacturers of Android devices have implemented support on their own (e.g. Sony Ericsson's ST and MT series phones seem to support Devanagari and other Indic scipts very well.) On some Android phones Indic scripts will render OK in the browser - because the browser developer has added support of their own - but will not work in other applications.

    Please see: http://code.google.com/p/android/issues/detail?id=4153

    Until this issue is properly fixed in Android, most devices running this operating system seem to be a poor choice for users who want to use scripts like Devanagari, Tamil, Bengali, Kannada, Punjabi, Telugu, Tibetan, Khmer, Sinhala, Malayalam, Burmese, and so on on their smart phone or tablet.

    The part of Android that needs fixing to support complex scripts is libskia.so and libwebcore.so. So, if you are writing applications to support Indian languages, you might want to try replacing these libraries with your own modified versions.

    0 讨论(0)
  • 2020-12-08 23:05

    Android supports Unicode out-of-the box. You're particular language might be not supported though. You can find list of supported locales for each SDK version by looking at Platform Notes.

    0 讨论(0)
  • 2020-12-08 23:12

    I liked the comprehensive answer from Sahaja.

    There are some efforts going on to port Harfbuzz-ng rendering engine to android. Here is a link to the source code of porting Harfbuzz-ng for kannada , one of the Indian languages, text rendering.

    0 讨论(0)
  • 2020-12-08 23:15

    Android does support Unicode, but the fonts included don't cover all Unicode characters, and the rendering doesn't support all types of scripts. In particular, the included fonts only cover Western European (Latin), Cyrillic, Greek, and CJK characters. Even if you install new fonts, it appears that Android does not properly support some forms of indic text layout like Devanagari, as mentioned in bug 4153. I'm not familiar enough with the Bengali script to know if it requires any sort of special rendering like Devanagari does, but if it does, then it is likely not supported on Android even if you install a font that supports it.

    0 讨论(0)
  • 2020-12-08 23:15

    You may be able to work around this with a specialised font, as seen in this SO answer about Tamil on Android.

    0 讨论(0)
提交回复
热议问题