How to Remove non-ascii characters from data
I have some code that gets caller ID Data. Everything works fine, but there are some non printing characters that cause problems when put into a database. How can I remove these characters? (the length of the received data varies by phone call) Thanks
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Kirtan PatelRank #292 · 8.6K reputationPosted Aug 5, 2009, 12:41 PM EDT
private void button1_Click(object sender, EventArgs e) { string Data = textBox1.Text; char[] DataArray = Data.ToCharArray(); string NewData = ""; foreach (char c in DataArray) { int cint = Convert.ToInt32(c); if (cint = 0) { NewData = NewData + c.ToString(); } } MessageBox.Show(NewData); }If you want to Use For Extended ASCII then change the Limit to 255 in that if condition
Happy Coding :)
patrickRank #4,458 · 342 reputationPosted Aug 5, 2009, 2:29 PM EDT