We help IT Professionals succeed at work.

How to convert á character to a and so on using c#

narlasridhar
narlasridhar asked
on
Medium Priority
476 Views
Last Modified: 2013-11-07
I am using the streamreader to open the file like below

StreamReader re = new StreamReader(sFilename, System.Text.Encoding.Default);
and my text file contains the characters like á
I am able to read them when i use stream reader.
But,I want those characters to be replaced like

á--a
etc

Thanks in advance
Comment
Watch Question

Top Expert 2009
Commented:
Unfortunately, this is not a trivial task. A broad description of the problem and the solution can be found here: http://www.codeproject.com/KB/cs/UnicodeNormalization.aspx, including sample code you can download. The page shows two approaches, but the first is by far the easiest and suits most needs.

A third approach would be to use XSLT2/XPath2 functions, as they support normalization (the name for this task) out of the box. It is a bit of overkill, but you can take the Saxon.Net libraries (10MB!) and use an XPath expression on your string to normalize them. If you want to go that path I can help you setting it up (I've been there before).

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks for your immediate response.
Top Expert 2009

Commented:
You're welcome ;)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.