views:

21

answers:

1

I have a string that looks like this " Into" and I can't figure out what the " " value is just before the Into. It's not a space, it's not an enter. At least i don't think so. I've tried doing a replace to get rid of it..

So now i'm just trying to figure out what that character value is. Convert.int32 doesn't get it done... What can i use to get rid of that character... I guess i could write a function that would loop through the alphabet and do it that way.. but figured there was a better way.

thanks shannon

+2  A: 

Have you tried using Trim() which removes all leading and trailing whitespace from a string?

e.g. (C#)

string cleanString = dirtyString.Trim();

To find the ASCII val of the "mystery" character:

int charVal = (int)dirty.ToCharArray()[0];

P.S. Wouldn't it be more appropriate to ask about using C# or .NET to scrub a string?

EDIT

// algorithm for removing weird char from string

    string dirtyString = " sdfsf ";

    // get the offending character:
    char dirtyChar = dirtyString.ToCharArray()[0];

    // replace offending character with something known like an asterisk
    string cleanString = dirtyString.Replace(dirtyChar, '*');

    // remove asterisk from string
    cleanString = cleanString.Replace("*", "");
Paul Sasik