Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert Hebrew Letters into Equivalent Number

Tags:

c#

hebrew

Other then hard coding this by hand I was wondering if there was a way that the.net framework would have this built in automaticaly, I know it can automatically convert hebrew dates into georgian dates but I need to convert hebrew numbers into georgian

IE א = 1 ב = 2

This goes into the hundreds. See here for more info.

like image 555
user511046 Avatar asked Feb 26 '23 18:02

user511046


1 Answers

Here is the approach that you should take:

  1. Make Dictionary<char,int> that gives correspondence between each Hebrew letter and its numeric value
  2. Parse the string one character at a time (best to do it right-to-left)
  3. For each character, look up its value in the dictionary and add it to a running sum
  4. Be sure to handle common scenarios for separating the hundreds-letters from the tens-letters (double-quotation mark) and separating the thousands-letters from the hundreds (single-quotation mark). For example, 5770 = ה'תש"ע.`. See the details in the link above for more on separations.

Edit: I just published a GitHub Repo that exposes functionality for converting Hebrew text to numbers, and numbers to their Hebrew letter equivalents.

like image 78
Yaakov Ellis Avatar answered Mar 06 '23 23:03

Yaakov Ellis