I found the below post what exactly I was looking for. I was posting the 3PL information to the warehouse endpoint and they were rejecting the files where there were some accents in the addresses/delivery names.
The below code helped me to solve the problem. Please change the code according to your requirement.
static void AlexRemoveDiacritics(Args _args) { str strInput = 'ÁÂÃÄÅÇÈÉàáâãäåèéêëìíîïòóôõ£ALEX'; System.String input = strInput; str retVal; int i; System.Char c; System.Text.NormalizationForm FormD = System.Text.NormalizationForm::FormD; str normalizedString = input.Normalize(FormD); System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); for (i = 1; i <= strLen(normalizedString); i++) { c = System.Char::Parse(subStr(normalizedString, i, 1)); if (System.Globalization.CharUnicodeInfo::GetUnicodeCategory(c) != System.Globalization.UnicodeCategory::NonSpacingMark) { stringBuilder.Append(c); } } input = stringBuilder.ToString(); input = input.Normalize(); retVal = input;
retVal = System.Text.RegularExpressions.Regex::Replace(retVal, @"[^\w\.@-]", " ");// This
// will remove any non-printable ASCII characters from a string
info(strFmt("Before: '%1'", strInput)); info(strFmt("After: '%1'", retVal)); }
It was a great information and Its really worth reading it.
ReplyDeleteMicrosoft Dynamics AX Training
MS Dynamics AX Training
MS Dynamics Training in Hyderabad
Microsoft Dynamics AX Technical Training