Question Find and Replace Unicode Default Char � OR �

susiekmart

New member
Joined
Jul 22, 2011
Messages
3
Programming Experience
1-3
I used a StreamReader and StreamWriter with UTF-8 encoding to find and replace chars in files. Some of the chars were replaced with the Unicode default char of � OR �. I found that for this I should have used encoding 1252 so I'm set for future changes but how do I fix the files that have been cluttered with the default char? Is there a way to do this with StreamReader?
 
how do I fix the files that have been cluttered with the default char?
I don't think it is possible to restore that information. The only option would be to load file as utf-8 and save as 1252, but if char information was lost when reading as utf-8 then the actual source is lost.
 
Thanks JohnH.

Luckily, I don't have to restore it to it's previous state. The users have agreed to allow the chars to be changed to a space. I'd like to run the same code (using the proper encoding) to find the Unicode Default Char and change it to a space. So far I can find nothing that will recognize that char.
 
s = s.Replace("�"c," "c)
 
You are my hero!!

It took a little research to learn that the c is converting a string to a char.

s = s.Replace("�"c," "c)

Very slick and works great.

Thank you!!
 
Back
Top