Umlaut causing problems in merchant process

written by Jason Short on Wednesday, December 03 2008

An interesting note for everyone.  We had a user today contact us about the new payment processor failing on his account.  After some research we finally determined that the problem was with his address being rejected at the payment gateway.  The address has an o umlaut in it (pretty common I would think).

The solution was to remove the umlaut from the string before submission.  I found this code through Google, but thought I would post it here since it was so useful.

The database has no problems with the accent, neither does asp.net.  It was just our payment gateway.  If we include an umlaut they hang up on us, otherwise they work.  Strange.  We have sent the samples to them as well for their review.

Strip Accent Characters

 

        private string RemoveAccents(string input)
        {
            string normalized = input.Normalize(NormalizationForm.FormKD);
            StringBuilder builder = new StringBuilder();
            foreach (char c in normalized)
            {
                if (char.GetUnicodeCategory(c) != UnicodeCategory.NonSpacingMark)
                {
                    builder.Append(c);
                }
            }
            return builder.ToString();
        }

Similar Posts

  1. Dogfooding, Entity Framework and LINQ
  2. Exposing strongly typed interfaces that are not CLS Compliant
  3. LINQ test for custom IEnumerator

Comments are closed

Options:

Size

Colors