Android: Character appearing as a box
I have an app displaying Japanese characters but for some reason, the tilde (~) character is displaying as a box (which looks like this, but one character: []).
This is after i apply the text to a TextView. I got the text from a JSON string.
The thing that disturbs me is, aren't Java strings unicode? Anyone know what i need to开发者_C百科 fix?
characters = getCharacterFromJSON();
// set character
TextView charTextView = (TextView)findViewById(R.id.characterView);
charTextView.setText(characters);
// Ack! all my ~'s are []!
EDIT: it's not a tilde(~), it's a japanese character (〜), which indicates these characters are a suffix. It's still not showing though.
Most probably a font issue. The default font that comes with most Android devices doesn't properly support all Japanese characters: some kanji are shown using the Chinese glyph, more obscure characters are not displayed at all (boxes). You have a few options:
- if this is for your own use, and you have are rooted phone, install the DroidSansJapanese.ttf font (copy to
/system/fonts
) - if it's an app you want to distribute, bundle the font in assets, and set your text views to use it
精彩评论