If you want to remove diacritics (accents on letters) from strings like this "ÁÂÃÄÅÇÈÉàáâãäåèéêëìíîïòóôõ£ALEX" to use the more friendly string "AAAAAACEEaaaaaaeeeeiiiioooo£ALEX", you can use this block of code:
It is still very useful.
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; info(strFmt("Before: '%1'", strInput)); info(strFmt("After: '%1'", retVal)); }
It is still very useful.
No comments:
Post a Comment