0

when trying to display text in a textView whit special chars like this öäå they appear like this ���. I display the text like this tv.setText("åäö");

As I understand it you can't encode a TextView, so how do I make sure it is read as utf-8?

zexuz
  • 145
  • 8
  • Have you had a look at This question: http://stackoverflow.com/questions/18951741/encoding-in-android-textview ? – Raphaël Jun 22 '15 at 15:27
  • 1
    start by making sure your source code is utf-8 – njzk2 Jun 22 '15 at 15:29
  • @Raphaël yes but i don't understand what the 'c' is in "c.getString("NAME")" – zexuz Jun 22 '15 at 15:39
  • @njzk2 I think it is this to for even when I hard coded a webView whit "öäå" is didn't work. But I have already tried to change source code encoding.. – zexuz Jun 22 '15 at 15:43
  • 1
    the simplest way would be to put your string in the strings.xml file, which is always utf-8 encoded in android studio. – njzk2 Jun 22 '15 at 15:46
  • Set your IDE preferences to use UTF-8. – Phantômaxx Jun 22 '15 at 15:48
  • also, in android studio, go to `Preferences -> Editor -> File Encoding`, make sure IDE and Project are set to UTF-8 – njzk2 Jun 22 '15 at 15:48
  • @njzk2 ... yes, exactly. – Phantômaxx Jun 22 '15 at 15:50
  • @njzk2 tried it twice now, even restarted ADB,Android studio and the running emulator. Not working. – zexuz Jun 22 '15 at 15:58
  • @user2034253 Are you using getResources().getString(R.string.yourString); to get your string from a string.xml file ? As njzk2 said, that might also help... – Raphaël Jun 22 '15 at 16:00
  • @Raphaël when i do this it works grate, the problem is the files I'm read from is huge like 1000 rows whit statements and I want a random one. Getting a R.string.myString is a pain in the a** and putting in 1000 row is also a pain in the a** – zexuz Jun 22 '15 at 16:09
  • Are you converting that said string in UTF-8 ? is the file you are reading from in utf-8 ? if not to any of those answers, you probably need to encode/convert your input/read into utf-8 – Raphaël Jun 22 '15 at 16:25
  • @Raphaël yes I need to do this, not doing it now because tv.setText("åäö") should work fine? – zexuz Jun 22 '15 at 16:48
  • May depend of a few factors that are going on on your environnement/ide/code/device... Why not do it explicitly ? – Raphaël Jun 22 '15 at 17:49

0 Answers0