How can i convert English digits to Arabic digits?

前端 未结 7 800
有刺的猬
有刺的猬 2020-11-27 20:59

I have this C# code for example

DateTime.Now.ToString(\"MMMM dd, yyyy\");

Now the current thread is loading the Arabic culture. So the resu

7条回答
  •  清歌不尽
    2020-11-27 21:49

    Try this:

    public static string ToIndicDigits(this string input)
    {
            return input.Replace('0', '\u0660')
                    .Replace('1', '\u0661')
                    .Replace('2', '\u0662')
                    .Replace('3', '\u0663')
                    .Replace('4', '\u0664')
                    .Replace('5', '\u0665')
                    .Replace('6', '\u0666')
                    .Replace('7', '\u0667')
                    .Replace('8', '\u0668')
                    .Replace('9', '\u0669');
        }
    }
    

提交回复
热议问题