Reputation: 1577
Some kanji characters output on buttons as spaces. The string is utf-8 but I've tried utf-16 and that didn't work. I'm using button.setText to set the value. I can do setText followed by getText and see that I'm getting the same character back. Character output works find in Log.i. I tried setting the font to DroidSansJapanese.ttf and thinking that the characters weren't supported by the default font and that didn't help.
I think this is probably a unicode problem but don't know where to look from here.
The image below shows the character and its codepoint. It looks like characters above 0xFFFF are the problem.
Here is how I'm setting the font:
jFont = Typeface.createFromAsset(
getActivity().getAssets(), "fonts/DroidSansJapanese.ttf");
Here's the code from the adapter doing the setText:
public View getView(int position, View convertView, ViewGroup parent) {
Button button = (Button) convertView;
KanjiInfo ki = getItem(position);
if (ki.isChanged() || null == button) {
button = new Button(context);
button.setTypeface(jFont);
}
String s = ki.kanjiChar();
String buttonText = String.format("%s:0x0%X", s, s.codePointAt(0));
button.setText(buttonText);
s = button.getText().toString();
Log.i(logTag, String.format("position=%d, s=\"%s\", codepoint=0x%08X",
position, s, s.codePointAt(0)));
...
Edited output from Log.i looks like:
position=42, s="齩:0x09F69", codepoint=0x00009F69
position=43, s="𣏤:0x0233E4", codepoint=0x000233E4
position=44, s="𨨞:0x028A1E", codepoint=0x00028A1E
I've spent several days on this and am out of ideas. Any ideas would be appreciated.
Upvotes: 0
Views: 280
Reputation: 536567
I tried setting the font to DroidSansJapanese.ttf and thinking that the characters weren't supported by the default font and that didn't help.
Yeah, it would appear U+233E4 and U+28A1E are not included by DroidSansJapanese either, as it doesn't include anything outside the Basic Multilingual Plane.
Fonts that have them include Takao Gothic and Ming Li U.
Upvotes: 1