如何在Android中通过其Unicode打印非英语文本

huangapple 未分类评论43阅读模式
英文:

How do I print non English text from its unicode in Android

问题

我需要在其自身的语言中显示非英语文本。例如:将日语名称显示为日语。

以下是代码,

String.format(Locale.JAPANESE, "%s %s", "%E9%A6%96%E7%9B%B8", "%E9%A6%96%E7%9B%B8");

这个代码的输出是:%E9%A6%96%E7%9B%B8

转换没有起作用。但是如果我打印日语文本(而不是 Unicode),它会显示在 Android 屏幕上,所以不是字体问题。
我在这里阅读了类似的问题和答案,但没有一个对我起作用。
请帮忙。

英文:

I need to display non English text in it's own language. Ex: Japanese name in Japanese

This is the code,

   String.format(Locale.JAPANESE,"%s %s","%E9%A6%96%E7%9B%B8","%E9%A6%96%E7%9B%B8");

The out put for this is : %E9%A6%96%E7%9B%B8

The converting not work. But if I print Japanese text(not the unicode), it is displaying on Android screen so not a font issue.
I read similar questions and answers here and non of them work for me.
Please help.

答案1

得分: 0

对于Unicode,你可以尝试,比如你有一个TextView:

textView.setText(Html.fromHtml(your_unicode_here));

如果你需要进行翻译,我建议你使用翻译API或者一个带有日语、英语字符串等的硬编码映射解决方案。

英文:

For unicode, you can try, say you have a TextView:

textView.setText(Html.fromHtml(your_unicode_here));

If you need to translate it, I suggest you use a translation API or a hard-coded mapped solution w/ Japanese, English strings etc.

huangapple
  • 本文由 发表于 2020年4月8日 14:25:55
  • 转载请务必保留本文链接:https://java.coder-hub.com/61094503.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定