Read Hidden characters from a text file

Nov 12 2010 1:06 PM
I have a text file which I attached in this post.I read this file using StreamReader in c# and insert into SQL. When I try to insert the data,I get error.I was trying to find the problem for that i tried removing the text word by word from the text file and trying the code again.Finally I found the problematic part , removed it and successfully inserted into SQL . When I copy the text and paste into notepad ,there is nothing I could observe. . After spending some time I decided putting into word. I copied the text and paste into word 2007 and found the problem.The problematic text has hidden characters in it. The character is "--" . Two hyphens or dashes. According to my research , SQL database does not accept this Character sequence against SQL injection .After finding the issue, I tried to fix it. What I tried is , read the text file and if i see that sequence replace with new characters . I tried stream reader to read the text file but i can not find the hidden characters with stream reader . what is the best way to read hidden characters with c# . 
I attached the file if you open in word you see the characters also in notepad++ . But not in notepad

Answers (4)