user511046
user511046

Reputation: 199

Convert Hebrew Letters into Equivalent Number

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.

Upvotes: 4

Views: 3239

Answers (1)

Yaakov Ellis
Yaakov Ellis

Reputation: 41490

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.

Upvotes: 8

Related Questions