This is probably an easy one (it may even be a dupe), but I cannot find answer to this - how to print number using Hebrew letters?
I've tried to change app language and/or using format provider:
myTextBox.Text = 555.ToString(new System.Globalization.CultureInfo("he-IL"));
but I can't get Hebrew letters.
As Zohar says, in most uses Hebrew uses the same Indo-Arabic digits as English. If you really do want to write out a number using Hebrew letters though, a simple approach is:
public static string FormatHebrew(this int num)
{
if(num <= 0)
throw new ArgumentOutOfRangeException();
StringBuilder ret = new StringBuilder(new string ('ת', num / 400));
num %= 400;
if(num >= 100)
{
ret.Append("קרש"[num / 100 - 1]);
num %= 100;
}
switch(num)
{
// Avoid letter combinations from the Tetragrammaton
case 16:
ret.Append("טז");
break;
case 15:
ret.Append("טו");
break;
default:
if (num >= 10)
{
ret.Append("כלמנסעפצי"[num / 10 - 1]);
num %= 10;
}
if(num > 0)
ret.Append ("אבגדהוזחט" [num - 1]);
break;
}
return ret.ToString ();
}
(Do make sure your text editor handles the ordering of the strings correctly, the main thing is that the source code as seen by the compiler has them in lower-to-higher order. A good text-editor will show that as right-to-left as that's the order Hebrew uses, but some will show it reversed from that).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With