Note that there are some explanatory texts on larger screens.

plurals
  1. POUnicode characters not displayed in TextView.setText
    primarykey
    data
    text
    <p>I can't get a TextView to correctly dynamically display unicode characters, and it's driving me batty. I've stripped it down to the bare minimum, but the TextView populated by setText still shows diamonds with question marks inside them for the unicode characters. The version populated from strings.xml shows the multibyte characters perfectly. Here's the activity:</p> <pre><code>public class TestMultibyteActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); setContentView( R.layout.main ); TextView textField = (TextView) findViewById( R.id.text_field ); String str = "Tübingen systemportefølje"; Log.d( "MULTIBYTE", str ); //note that this prints the multibyte chars correctly. //EDIT: oh crap, no it doesn't. might be onto something here... textField.setText( str ); } } </code></pre> <p>And here's the layout:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt; &lt;TextView android:id="@+id/text_field" android:layout_width="fill_parent" android:layout_height="wrap_content"/&gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/unicodechars"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>Here's strings.xml:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;resources&gt; &lt;string name="app_name"&gt;TestMultibyteActivity&lt;/string&gt; &lt;string name="unicodechars"&gt;Tübingen systemportefølje&lt;/string&gt; &lt;/resources&gt; </code></pre> <p>I'm building with ant. Here's my default.properties:</p> <pre><code>target=Google Inc.:Google APIs:8 </code></pre> <p>And here's my AndroidManifest.xml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mycompany.android.multibyte" android:versionCode="1" android:versionName="1.0"&gt; &lt;application android:label="@string/app_name" android:icon="@drawable/icon"&gt; &lt;activity android:name="TestMultibyteActivity" android:label="@string/app_name"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>I've tinkered with everything I can think of, but it seems like unicode characters are getting split by the CharSequence interface, and I can't figure out why.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload