How do I to convert different Unicode characters to their closest ASCII equivalents? Like Ä -> A. I googled but didn't find any suitable solution. The trick Encoding.ASCII.GetBytes("Ä")[0]
didn't work. (Result was ?
).
I found that there is a class Encoder
that has a Fallback
property that is exactly for cases when char
can't be converted, but implementations (EncoderReplacementFallback
) are stupid and convert to ?
.
Any ideas?
If it is just removing of the diacritical marks, then head to this answer:
MS Dynamics has a problem where it won't allow for any character outside of x20 to x7f and some characters within that range are also invalid. My answer was to create an array keyed to the invalid characters returning the best guess of the valid characters.
It ain't pretty, but it works.
Your answer is necessarily going to be different.