0

When I attempt to display kanji a Label on Android, it gets displayed as Chinese instead of Japanese

For example, the difference between the character "直" in Chinese and Japanese:

Chinese vs Japanese

(see here for more examples)

According to this post, Android chooses the default based on whether or not the user has Japanese installed as a language.

Is there any way to tell it to pick the Japanese encoding?

BlueRaja - Danny Pflughoeft
  • 84,206
  • 33
  • 197
  • 283
  • Maybe you can add the custom font(display japanese test) to your Xamarin.Forms shared project as an embedded resource, register the font file with the assembly, you can take a look:[Set the font family](https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/fonts#set-the-font-family) – Cherry Bu - MSFT Jun 02 '21 at 03:21

1 Answers1

0

A solution involving a custom renderer:

Android project:

[assembly: ExportRenderer(typeof(Label), typeof(JapaneseLabelRenderer))]
namespace MyProject.Controls
{
    public class JapaneseLabelRenderer : LabelRenderer
    {
        public JapaneseLabelRenderer(Context context) : base(context) { }

        protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
        {
            base.OnElementChanged(e);
            Control.TextLocale = Locale.Japan;
        }
    }
}
BlueRaja - Danny Pflughoeft
  • 84,206
  • 33
  • 197
  • 283