Skip to main content

C# method to determine if a specified string is ASCII encoded.

private static bool IsAscii(string input)
{
    foreach (char c in input)
    {
        if (c < 32 || c >= 127)
        {
            return false;
        }
    }

    return true;
}