Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5964275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:24:07+00:00 2026-05-22T19:24:07+00:00

Some of our users use e-mail clients that can’t cope with Unicode, even when

  • 0

Some of our users use e-mail clients that can’t cope with Unicode, even when the encoding, etc. are properly set in the mail headers.

I’d like to ‘normalise’ the content they’re receiving. The biggest problem we have is users copy’n’pasting content from Microsoft Word into our web application, which then forwards that content by e-mail – including fractions, smart quotes, and all the other extended Unicode characters that Word helpfully inserts for you.

I’m guessing there is no definitely solution for this, but before I sit down and start writing great big lookup tables, is there some built-in method that’ll get me started?

There’s basically three phases involved.

First, stripping accents from otherwise-normal letters – solution to this is here

This paragraph contains “smart quotes” and áccénts and ½ of the problem is fractions

goes to

This paragraph contains “smart quotes” and accents and ½ of the problem is fractions

Second, replacing single Unicode characters with their ASCII equivalent, to give:

This paragraph contains "smart quotes" and accents and ½ of the problem is fractions

This is the part where I’m hoping there’s a solution before I implement my own. Finally, replacing specific characters with a suitable ASCII sequence – ½ to 1/2, and so on – which I’m pretty sure isn’t natively supported by any kind of Unicode magic, but somebody might have written a suitable lookup table I can re-use.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T19:24:08+00:00Added an answer on May 22, 2026 at 7:24 pm

    Thank you all for some very useful answers. I realize the actual question isn’t “How can I convert ANY Unicode character into its ASCII fallback” – the question is “how can I convert the Unicode characters my customers are complaining about into their ASCII fallbacks” ?

    In other words – we don’t need a general-purpose solution; we need a solution that’ll work 99% of the time, for English-speaking customers pasting English-language content from Word and other websites into our application. To that end, I analyzed eight years’ worth of messages sent through our system looking for characters that aren’t representable in ASCII encoding, using this test:

    ///<summary>Determine whether the supplied character is 
    ///using ASCII encoding.</summary>
    bool IsAscii(char inputChar) {
        var ascii = new ASCIIEncoding();
        var asciiChar = (char)(ascii.GetBytes(inputChar.ToString())[0]);
        return(asciiChar == inputChar);
    }
    

    I’ve then been through the resulting set of unrepresentable characters and manually assigned an appropriate replacement string. The whole lot is bundled up in an extension method, so you can call myString.Asciify() to convert your string into a reasonable ASCII-encoding approximation.

    public static class StringExtensions {
        private static readonly Dictionary<char, string> Replacements = new Dictionary<char, string>();
        /// <summary>Returns the specified string with characters not representable in ASCII codepage 437 converted to a suitable representative equivalent.  Yes, this is lossy.</summary>
        /// <param name="s">A string.</param>
        /// <returns>The supplied string, with smart quotes, fractions, accents and punctuation marks 'normalized' to ASCII equivalents.</returns>
        /// <remarks>This method is lossy. It's a bit of a hack that we use to get clean ASCII text for sending to downlevel e-mail clients.</remarks>
        public static string Asciify(this string s) {
            return (String.Join(String.Empty, s.Select(c => Asciify(c)).ToArray()));
        }
    
        private static string Asciify(char x) {
            return Replacements.ContainsKey(x) ? (Replacements[x]) : (x.ToString());
        }
    
        static StringExtensions() {
            Replacements['’'] = "'"; // 75151 occurrences
            Replacements['–'] = "-"; // 23018 occurrences
            Replacements['‘'] = "'"; // 9783 occurrences
            Replacements['”'] = "\""; // 6938 occurrences
            Replacements['“'] = "\""; // 6165 occurrences
            Replacements['…'] = "..."; // 5547 occurrences
            Replacements['£'] = "GBP"; // 3993 occurrences
            Replacements['•'] = "*"; // 2371 occurrences
            Replacements[' '] = " "; // 1529 occurrences
            Replacements['é'] = "e"; // 878 occurrences
            Replacements['ï'] = "i"; // 328 occurrences
            Replacements['´'] = "'"; // 226 occurrences
            Replacements['—'] = "-"; // 133 occurrences
            Replacements['·'] = "*"; // 132 occurrences
            Replacements['„'] = "\""; // 102 occurrences
            Replacements['€'] = "EUR"; // 95 occurrences
            Replacements['®'] = "(R)"; // 91 occurrences
            Replacements['¹'] = "(1)"; // 80 occurrences
            Replacements['«'] = "\""; // 79 occurrences
            Replacements['è'] = "e"; // 79 occurrences
            Replacements['á'] = "a"; // 55 occurrences
            Replacements['™'] = "TM"; // 54 occurrences
            Replacements['»'] = "\""; // 52 occurrences
            Replacements['ç'] = "c"; // 52 occurrences
            Replacements['½'] = "1/2"; // 48 occurrences
            Replacements['­'] = "-"; // 39 occurrences
            Replacements['°'] = " degrees "; // 33 occurrences
            Replacements['ä'] = "a"; // 33 occurrences
            Replacements['É'] = "E"; // 31 occurrences
            Replacements['‚'] = ","; // 31 occurrences
            Replacements['ü'] = "u"; // 30 occurrences
            Replacements['í'] = "i"; // 28 occurrences
            Replacements['ë'] = "e"; // 26 occurrences
            Replacements['ö'] = "o"; // 19 occurrences
            Replacements['à'] = "a"; // 19 occurrences
            Replacements['¬'] = " "; // 17 occurrences
            Replacements['ó'] = "o"; // 15 occurrences
            Replacements['â'] = "a"; // 13 occurrences
            Replacements['ñ'] = "n"; // 13 occurrences
            Replacements['ô'] = "o"; // 10 occurrences
            Replacements['¨'] = ""; // 10 occurrences
            Replacements['å'] = "a"; // 8 occurrences
            Replacements['ã'] = "a"; // 8 occurrences
            Replacements['ˆ'] = ""; // 8 occurrences
            Replacements['©'] = "(c)"; // 6 occurrences
            Replacements['Ä'] = "A"; // 6 occurrences
            Replacements['Ï'] = "I"; // 5 occurrences
            Replacements['ò'] = "o"; // 5 occurrences
            Replacements['ê'] = "e"; // 5 occurrences
            Replacements['î'] = "i"; // 5 occurrences
            Replacements['Ü'] = "U"; // 5 occurrences
            Replacements['Á'] = "A"; // 5 occurrences
            Replacements['ß'] = "ss"; // 4 occurrences
            Replacements['¾'] = "3/4"; // 4 occurrences
            Replacements['È'] = "E"; // 4 occurrences
            Replacements['¼'] = "1/4"; // 3 occurrences
            Replacements['†'] = "+"; // 3 occurrences
            Replacements['³'] = "'"; // 3 occurrences
            Replacements['²'] = "'"; // 3 occurrences
            Replacements['Ø'] = "O"; // 2 occurrences
            Replacements['¸'] = ","; // 2 occurrences
            Replacements['Ë'] = "E"; // 2 occurrences
            Replacements['ú'] = "u"; // 2 occurrences
            Replacements['Ö'] = "O"; // 2 occurrences
            Replacements['û'] = "u"; // 2 occurrences
            Replacements['Ú'] = "U"; // 2 occurrences
            Replacements['Œ'] = "Oe"; // 2 occurrences
            Replacements['º'] = "?"; // 1 occurrences
            Replacements['‰'] = "0/00"; // 1 occurrences
            Replacements['Å'] = "A"; // 1 occurrences
            Replacements['ø'] = "o"; // 1 occurrences
            Replacements['˜'] = "~"; // 1 occurrences
            Replacements['æ'] = "ae"; // 1 occurrences
            Replacements['ù'] = "u"; // 1 occurrences
            Replacements['‹'] = "<"; // 1 occurrences
            Replacements['±'] = "+/-"; // 1 occurrences
        }
    }
    

    Note that there are some rather odd fallbacks in there – like this one:

    Replacements['³'] = "'"; // 3 occurrences
    Replacements['²'] = "'"; // 3 occurrences
    

    That’s because one of our users has some program that converts open/close smart-quotes into ² and ³ (like : he said ²hello³) and nobody has ever used them to represent exponentiation, so this will probably work quite nicely for us, but YMMV.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have some files on our website that users of our software can download.
I have a table containing data about some users. Many of them use our
Some of our FogBugz users experience that the Screenshot tool does not start-up automatically
I'm working on a small project that requires some of our users to be
We have a common database schema that we use for some tables in our
We use jquery for a slider and for some users in our company who
Many of our users, internal and external, start our web application. Then at some
I just picked up the Google API today to allow some users of our
I have a site where some users will be registered by our staff, and
I'm using the Jetpack theme in an application that some use of Datagrids. When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.