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.
Here is the approach that you should take:
Make Dictionary<char,int> that gives correspondence between each Hebrew letter and its numeric value
Parse the string one character at a time (best to do it right-to-left)
For each character, look up its value in the dictionary and add it to a running sum
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.
Related
I wan't to concatenate some id's in C# code to export to a specific data base. The problem is that data base use a specific symbol to concatenate the id's. The symbol used is like the symbol for the gender masculine (something like this: ♂). If I try to copy here I only get the '0' character. I also try to find his ascii code but I couldn't find it. I get the symbol by exporting data from file maker pro data base.
What I want is to create a array of id's concatenated by this strange symbol in C#. For example: 12[symbol]123[symbol]
Remember, ascii is what we used in the 1970's. You want the Unicode codepoint, not the ascii code. If you don't understand the difference then stop everything you are doing and read this before you write any more code:
http://www.joelonsoftware.com/articles/Unicode.html
The Mars symbol is the Unicode codepoint u2642, so in C# that would be
string mars = "\u2642";
When you have obtained the symbol in some way, just paste it into your source code:
string m = "♂";
The symbol a little different that this: ♂. The circle is smaller and the arrow is bigger
Although it's not impossible that there are 2 variations of a symbol in the Unicode space, the difference in appearance is probably due to different Fonts.
Still don't known the code for the symbol
As several people posted here, the code is 2642 and the C# notation is "Male(\u2642)" or simply type/paste "Male(♂)"
Is it possible to generate regular expressions from a user entered string? Are there any C# libraries to do this?
For example a user enters a string e.g. ABCxyz123 and the C# code automatically generates [A-Z]{3}[a-z]{3}\d{3}.
This is a simple string but we could have more complicated strings like
MON-0123/AB/5678-abc 2/7
Or
1234-678/abc::1234ABC?246
I already have a string tokeniser (from a previous stackoverflow question) so I could construct a regex from the list of tokens.
But I was wondering if there is a lib or C# code out there that’ll do it.
Edit: Important, I should of also said: It's not the actual character in the string that are important but the type of character and how many.
e.g A user could enter a "pattern" string of ABCxyz123.
This would be interpreted as
3 upper case alphas followed by
3 lower case alphas followed by
3 digits
So other users (when complied) must enter strings that match that pattern [A-Z]{3}[a-z]{3}\d{3}., e.g. QAZplm789
It's the format of user entered strings that's need to be checked not the actual content if that makes sense
Jerry has a related link
creating a regular expression for a list of strings
There are a few other links off this.
I'm not trying to do anything complicated e.g NLP etc.
I could use C# expression builder and dynamic linq at a push, but that seems overkill and a code maintainable nightmare .
I'll write my own "simple" regex builder from the tokenized string.
Example Use Case:
An admin office user where I work could setup the string patterns for each field by typing a string pattern, My code converts this to a regex, I store these in a database.
E.g: Field one requires 3 digits at the start. If there are 2 digits then send to workflow 1 if 3 then send to workflow 2. I could simply check the number of chars by substr or what ever. But this would be a concrete solution.
I am trying to do this generically for multiple documents with multiple fields. Also, each field could have multiple format checkers.
I don't want to write specific C# checks for every single field in numerous documents.
I'll get on with it, should keep me amused for a couple of days.
I'm calling Microsoft translator for converting arabic names to english
But it translates the names , i just want to convert the names
for example:
أحمد ماهر
need to be
Ahmed Maher
the service is working but it translates the meaning of the names not just the names
I don't know about other languages but for your example
أحمد ماهر = Ahmed Maher
What I know is romanizations doesn't work with it
Why? because of the inflection and the letters "movements" that give the one letter more than one pronunciation. for example
مَح = Mah
مُح = Muh
Same letters but with a different pronunciation.
The solution that I've made is rules to convert the names
You can find the code and the npm package that I've made.
If you got any questions, issues or you tried to understand the rules for the Arabic I will be happy to help.
Please check below to know more about the needed rules to convert an Arabic name:
First Letter Rule
I am checking if the letter was the first letter since if the letter “و” was the first one people tend to write it “W” but if it was inside the word it will be written “O”.
Inner Letter Rule
By this I mean all the letters that are not the first nor the last and it will be changed based letter like the first image “م” will equal “H”
Next Letter Rule
In this rule am checking the letter and the upcoming one. like
if the letter was “م” and the next one was “ع” it should be written ”Mua”
if the letter was “م” and the next one was “ي” it should be written “May”

Special Letter Rule
It looks like the next letter rule but it will include another action like “slice”
ex: in the “First Letter Rule” I said that “و” inside the word will be converted to “O”
.”ا" I will need to delete the “O” and put a “w” then “A” for the ”ا“ But if the next letter was And I believe this rule could be enhanced but it’s important to have.
Last Letter Rule
Without this rule, the name “Sarah” will be converted from Arabic to “Sara”
This rule checks if the last letter is “ه“ ”ة” if it is it will add the “H” to complete the name.
Sounds like you want a character substitution, not a true translator. You could build your own transliterator with String.Replace.
Someone asked a similar question about transliterating Cyrillic to Latin:
How to transliterate Cyrillic to Latin text
If it is on a web site, you can enable the Collaborative Translations Framework functionality in the Widget, and use that to 'override' the translation into a name.
The API also supports this if you are building an app.
Widget documentation is here: http://blogs.msdn.com/b/translation/p/ctf1.aspx
and here: http://blogs.msdn.com/b/translation/p/ctf2.aspx
Please tell me how can i show symbols like "lambda" or Mu using c#.net in desktop application. what i think is we may do it using ASCII values and convert.toChar();.. if i am right that please give me link of page where i can get ASCII values of all such a scientific symbols.
Please give me link of any URL which contains list of such a ASCII numbers.
Open the Windows character map (charmap.exe), select a Unicode font (Arial should suffice) and copy the symbols into your source code or resources. It's just characters. Of course, you can also switch to Greek keyboard layout, so you can write the characters directly rather than going the charmap route.
Note that you need to use a Unicode font for the labels. You can use charmap to look up which font has Greek characters.
Please tell me how can i show symbols like "lambda" or Mu using c#.net in desktop application.
You don't have to do anything special. Just use whatever letters you want in either the IDE or in strings in the program. C# treats Greek letters the same as any other letters; they are not special.
what i think is we may do it using ASCII values and convert.toChar();
Hold on, I have a phone call. Oh, it's for you. It's 1968 calling, and they want their character set back. :-)
ASCII proper only has 95 printable characters, and Greek letters are not among them. ASCII was invented for teletypes back in the 1960's; we don't use it anymore. Characters in modern programming environments are represented using Unicode, which provides uniform support for tens of thousands of characters in dozens of alphabets.
if i am right then please give me link of page where i can get ASCII values of all such a scientific symbols.
You can get a list of all the Unicode characters at unicode.org. But like I said, you don't need to. You can just embed the character you want directly in the text. There's no need to resort to clumsy tricks like unicode escapes. (Unless, of course, you are planning on sending your source code to your coworkers using a 1970's era teletype machine.)
C# applications are all Unicode - so there should be no problem assigning Unicode strings to the controls' text, for example:
textBox1.Text = "this is a lambda symbol - λ";
Try this
char c = '\u03BB'; //03BC
System.Console.WriteLine(c.ToString());
does it work for you?
I have a Excel Spreadsheet with lab data which looks like this:
µg/L (ppb)
I want to test for the presence of the Greek letter "µ" and if found I need to do something special.
Normally, I would write something like this:
if ( cell.StartsWith(matchSequence) ) {
//.. <-- universal symbol for "magic" :)
}
I know there is an Encoding API in the Framework, but should I use it for just this one edge-case or just copy the Greek micro symbol from the character map?
How would I test for the presence of a this unicode character? The character map seems like a "cheap" fix that will bite me later (I work for a company which is multinational).
I want to do something that is maintainable and not just some crazy math-voodoo conversion that only works for this edge case.
I guess I'm asking for best practice advice here.
Thanks!
You need to work out the unicode character you're interested in, then you can represent it with in code with an escape sequence.
For example, µ is U+00B5, so you just need:
if (text.Contains("\u00b5"))
You can find out the Unicode value from charmap or from the Unicode code charts.
The Unicode code point for micro µ is U+00B5 and is different from the "Greek letter mu" µ, which is at U+03BC. So you can use "\u00b5" to find it, and possibly also look for "\u03bc" as well - they look the same, so whoever created the spreadsheet could have used the wrong one!
You can create a Char from the numeric equivelent shown to you in the Character Map (displays as U+0050 for 'P'). To do this simply check the contains:
string value;
if (value.Contains(Char.ConvertFromUtf32(0x0050)))
;
C# code files are usually encoded in utf8, since the language is using this encoding. All strings and strign literals in c# (and other .NET languages) are encoded in utf16. So you can safely copy the micro character from the character map.
You can also use its integer value as unicode literal like 0x1234.