tags:

views:

30

answers:

2

I'm just wondering if there is a method in .NET 2.0 that checks whether a character is printable or not – something like isprint(int) from standard C.

I found Char.IsControl(Char).

Could that be used for this purpose?

+1  A: 
private bool IsPrintableCharacter(char candidate)
{
    return !(candidate < 0x20 || candidate > 127);
}
moldovanu
+1  A: 

Or as an extension method.

public static bool IsPrintable(this char candidate){
    return !(candidate < 0x20 || candidate > 127);
}
JWL_