Beispiel #1
0
        internal static bool Contains(this List <string> values, StringSlice test)
        {
            foreach (var value in values)
            {
                if (test.Equals(value))
                {
                    return(true);
                }
            }

            return(false);
        }
        public static Encoding GetEncodingByName(StringSlice encodingName)
        {
            if (encodingName.IsEmpty)
            {
                return(null);
            }

            if (encodingName.Equals("UTF-8", StringComparison.OrdinalIgnoreCase) || encodingName.Equals("UTF8", StringComparison.OrdinalIgnoreCase))
            {
                return(Encoding.UTF8);
            }

            var encodingNameString = encodingName.ToString();

            try
            {
                return(Encoding.GetEncoding(encodingNameString));
            }
            catch (ArgumentException)
            {
                return(GetEncodingByAlternateNames(encodingNameString));
            }
        }