CCNet.Build.Common.Extensions.AsciiOnly C# (CSharp) Method

AsciiOnly() public static method

Filters out ASCII characters only, including some other specified characters.
public static AsciiOnly ( this text ) : string
text this
return string
		public static string AsciiOnly(this string text, params char[] includeAlso)
		{
			var map = new HashSet<char>(includeAlso);

			var sb = new StringBuilder();
			foreach (var c in text)
			{
				if ((c >= '0' && c <= '9')
					|| (c >= 'A' && c <= 'Z')
					|| (c >= 'a' && c <= 'z')
					|| map.Contains(c))
				{
					sb.Append(c);
				}
			}

			return sb.ToString();
		}