Unicode digit conversion from English to devanagari

I was looking for some RegEx or any other method to convert the digits 0-9 to 0-9 (devanagari script). I am using asp.net but could not find any method in the globalization namespace that does this.

Any help is greatly appreciated.

+4
source share
2 answers

Found a similar post here !

My decision is a little different, although I know the culture of the source and destination. Therefore, I can hard code the array of numbers.

string devYear = ""; string[] devD = { "реж", "рез", "реи", "рей", "рек", "рел", "рем", "рен", "рео", "реп" }; char[] digits = curYear.ToCharArray(); foreach (char ch in digits) { devYear += devD[int.Parse(ch.ToString())]; } 

Another change is that I repeat year digits instead of devD. Saves several iterations, since most numbers will be less than 10 digits. In my case, only four digits.

Hope this will be helpful for someone stuck on similar lines.

+1
source

Does each Latin digit 0..9 indicate exactly the Devanagari digit (I think so, if I understand Wikipedia correctly) =

If so, what about the following:

 public static string ConvertDigits( string s ) { return s .Replace("0", "реж") .Replace("1", "рез") .Replace("2", "реи") .Replace("3", "рей") .Replace("4", "рек") .Replace("5", "рел") .Replace("6", "рем") .Replace("7", "рен") .Replace("8", "рео") .Replace("9", "реп"); } 

For optimization, you can check string.IsNullOrEmpty() before calling the string.Replace function.

In addition (if this is suitable for the Devanagari digit), call the string.Replace() function to overload the function , which takes char as parameters, rather than string s.

0
source

All Articles