Display unicode characters in TextView Android

前端 未结 2 1553

There are a number of posts all over the internet on this topic, however none of them have been able to isolate and solve the problem.

I am trying to show some special U

相关标签:
2条回答
  • 2021-02-08 22:37

    It works on your Mac because the font used by your mac contains those special characters. It would be impossible to create a fontfile that contains all characters defined in unicode. Chinese fonts are a good example: none of them contain all of the ~60.000 known Chinese characters because the font file would be huge and unusable.

    You could try using the font from your Mac on android (might be copyright issues - try finding a free font that contains the characters: package the (ttf) file in your application, for example in the /assets folder, and then in your application load that font with

    TypeFace typeFace = Typeface.createFromAsset(assetmanager,"fontfile.ttf");

    You can then use this in a TextView like so:

    TextView view = (TextView) findById(R.id.mytext);

    view.setTypeFace(typeFace);

    0 讨论(0)
  • 2021-02-08 22:39

    If I'm understanding your situation correctly, you might want to consider the StringEscapeUtils.unescapeXml() method. It's in the common-lang.jar file available here: http://commons.apache.org/lang/

    It will take encoded symbols (for example ' for an apostrophe) and get you to a proper character.

    0 讨论(0)
提交回复
热议问题