string - C# Map all possible characters to the alphabet -


i'm trying map possible letters letters a-z, # numbers , maybe & other characters. i'm using normalize(normalizationform) method. gets rid of of unwanted characters characters accents , on.

however doesn't deal duplicates. seems letter m located in more 1 position , therefore equal-check fails.

here's code checks every possible letter:

for (uint = char.minvalue; <= char.maxvalue; i++) {     char normalizedchar = char.toupper($"{(char)i}".normalize(system.text.normalizationform.formkd).firstordefault());     if (char.isletter((char)i) && !allowedletters.contains(normalizedchar))         throw new exception(); } 

where allowedletters char array containing letters of alphabet , '#'.

it fails @ = 181 normalized 924 = 'm' 77 = 'm'.

i'm open better ways normalize character since method find works on strings.

the normalizationform msdn page explicitly warns this:

some unicode sequences considered equivalent because represent same character. (...) however, ordinal, is, binary, comparisons consider these sequences different because contain different unicode code values. before performing ordinal comparisons, applications must normalize these strings decompose them basic components.

that note "applications must normalize" means have work perform in application. suspect you're going have hand-mapping, ex map[char(924)] = char(77) or similar.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -