Example #1
0
        internal static string DtmfNormalize(string s)
        {
            if (string.IsNullOrEmpty(s))
            {
                return(s);
            }
            StringBuilder stringBuilder = new StringBuilder(s.Length);

            foreach (char c in s)
            {
                if (char.IsLetterOrDigit(c) || char.IsPunctuation(c))
                {
                    stringBuilder.Append(c);
                }
            }
            string text  = DtmfString.FoldString(stringBuilder.ToString());
            string text2 = text.Normalize(NormalizationForm.FormD);

            stringBuilder.Length = 0;
            foreach (char c2 in text2)
            {
                UnicodeCategory unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c2);
                if (unicodeCategory != UnicodeCategory.NonSpacingMark)
                {
                    stringBuilder.Append(DtmfString.NormalizeUsingTable(c2));
                }
            }
            return(stringBuilder.ToString());
        }
Example #2
0
        internal static string DtmfEncode(string s)
        {
            string        text          = DtmfString.DtmfNormalize(s);
            StringBuilder stringBuilder = new StringBuilder();

            foreach (char c in text)
            {
                char value;
                if (DtmfString.GetDtmf(c, out value))
                {
                    stringBuilder.Append(value);
                }
            }
            return(stringBuilder.ToString());
        }
Example #3
0
        private static string FoldString(string input)
        {
            int num = DtmfString.FoldString(DtmfString.MapFlags.MAP_EXPAND_LIGATURES, input, -1, null, 0);

            if (num == 0)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            StringBuilder stringBuilder = new StringBuilder(num);

            if (DtmfString.FoldString(DtmfString.MapFlags.MAP_EXPAND_LIGATURES, input, -1, stringBuilder, num) == 0)
            {
                throw new Win32Exception(Marshal.GetLastWin32Error());
            }
            return(stringBuilder.ToString());
        }