Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Convert Non-Standard ASCII Characters

Posted on 2006-05-02
Medium Priority
Last Modified: 2012-06-27
Is there any method available in C# that will convert any non-standard ASCII characters (characters > binary 128) into its equivalent standard ASCII characters.  Basically, I need to replace any 'ñ' in my string to 'n', 'á' into 'a', 'ú' into 'u', and others.  Aside from calling the String.Replace method, is there any other way without listing down/hard-coding all the non-standard ASCII characters with the corresponding replacement standard ASCII character.

Thanks for the help in advance.
Question by:rafrancisco
  • 2
LVL 55

Expert Comment

by:Jaime Olivares
ID: 16592302
I have never seen this function but you can create a table and a function, something like:

private char[] AsciiConversionTable = new char[128] { 'C','u','e','a','a','a','a','c','e','e','e','i','i','i','A','A', .....ETC...... };

public char ToAscii7Bits(char ascii)
     return (ascii<128) ? ascii : AsciiConversionTable[ascii-128];

Expert Comment

ID: 16592443
The "non-standard ASCII characters" which you listed are Latin characters.
In fact, the character 'ú' is not 'u', but 'w'.

public char LatinToEnglishChar(char ascii)
     return (ascii<131) ? ascii : ascii-131;
LVL 55

Accepted Solution

Jaime Olivares earned 2000 total points
ID: 16593417
>The "non-standard ASCII characters" which you listed are Latin characters.
>In fact, the character 'ú' is not 'u', but 'w'.

I don't know how you have concluded that. non-standard ASCII characters are almost all possible west european-languages characters (spanish, french, german, portugaise, etc.)
In spanish and many other languages ú is not w, is just an u with accent, even it is "legal" to represent without "adornments" when expressed in uppercase, like U.
There are some interesting exceptions like in german where: ü can be represented as "ue", ä as "ae" and ß as "ss".

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question