0

I have a string which contain some German language characters and Im setting in Textview but some characters are not showing but a box instead of them . here is code:

   @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_german);
        TextView abc = (TextView) findViewById(R.id.abc);
        String chararc = getString(R.string.german);

        try {
            final String s = new String(chararc.getBytes(), "UTF-8");
            abc.setText(s);
        } catch (UnsupportedEncodingException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_german, menu);
        return true;
    }
}

here is string :

 <string name="german">Ë ø  ë Ḧ ḧ Ï ï Ḯ ḯ M̈    m̈ N̈   n̈ Ö    ö Ȫ ȫ Ṏ ṏ P̈    p̈ S̈   s̈ T̈   ẗÜ  ü Ǖ ǖ Ǘ ǘ Ǚ ǚ Ǜ ǜ Ṳ ṳ Ṻ ṻ V̈    v̈ Ẅ    ẅ Ẍ ẍ Ÿ ÿ
</string>
Bibi Tahira
  • 1,082
  • 5
  • 15
  • 39
  • 1
    If you are using eclipse try this : `Right ckick on xml file` -> `Preferences` -> `XML` -> `XML Files` -> Change encoding to `UTF-8` -> OK. – AwadKab Mar 16 '13 at 10:00
  • Android works fine with non-english characters. The problem is in your text file, try to open it in Notepad++ and verify that its encoding is utf-8. – vortexwolf Mar 16 '13 at 11:08
  • Here is described the same problem that you have. http://stackoverflow.com/questions/8383889/german-characters-display-in-textview – Yakiv Mospan Jul 03 '13 at 08:45

2 Answers2

0

You should try using Html.fromHtml

...
abc.setText(Html.fromHtml(s));
...
StarsSky
  • 6,721
  • 6
  • 38
  • 63
0

If you created your project using the Android SDK Tools (read Creating an Android Project), the tools create a res/ directory in the top level of the project. Within this res/directory are subdirectories for various resource types. There are also a few default files such as res/values/strings.xml, which holds your string values.

Once you’ve decided on the languages you will support, create the resource subdirectories and string resource files. For example:

MyProject/
   res/
   values/
       strings.xml
   values-es/
       strings.xml
   values-fr/
       strings.xml
   values-de/
       strings.xml

Ref,Ref2

MuraliGanesan
  • 3,233
  • 2
  • 16
  • 22