Skip navigation

Sigh.

This snippet will remove non-printables from an ASCII string, because we will never be rid of it.

StringBuilder sb = new StringBuilder();
char[] chars = someString.ToCharArray();
for (int i = 0; i < chars.Length; i++)
{
  char c = chars[i];
  byte b = (byte)c;
  if (b < 32)
  {
     sb.Append(' ');
  }
  else
  {
    sb.Append(c);
  }
}
Advertisements

One Comment

  1. ,,,,, ,,,,,
    ..ooo*"""""""**ooo ooo**"""""""**ooo..
    .oo*" "*o o*" "*oo.
    .o" "o" "o.
    oo o oo
    .oo o oo.
    oo o oo
    oo o oo
    o% o %o
    o o o
    o. o .o
    "o o o
    oo o oo
    ^^o. ooo .o^^
    'ooo. .ooo. .ooo'
    "o ""oo,, ,,,oo-'-oo,,, ,,oo""o"
    o. """"""""" oo """"""""" .o
    'o oo o'
    *o oo o*
    'o oo o
    o oo o
    o oo o
    o oo o
    o oo o
    o oo o
    o oo o


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: