hello everyone .. i'm trying to modify a text in wich i want to replce some special characters with usual ones , but all i get are some other special characters (squares , question marks..)
my code looks like this :
CODE
void ApplyToFiles(string target)
{
string[] fnames;
fnames = Directory.GetFiles(".",target);
foreach (string fname in fnames)
{
FileInfo fi = new FileInfo(fname);
StreamReader sr = null;
StreamWriter sw = null;
try
{
sr = new StreamReader(new FileStream(fname, FileMode.Open, FileAccess.Read), Encoding.UTF8);
sw = new StreamWriter(new FileStream("NEW" + fi.Name, FileMode.Create), Encoding.UTF8);
Console.SetOut(sw);
String line = "";
while ((line = sr.ReadLine()) != null)
{
string nLine = Regex.Replace(line, "º", "s");
nLine = Regex.Replace(line, "ª", "S");
Console.Out.WriteLine(nLine);
}
}
finally
{
sr.Close();
Console.Out.Close();
}
the code works only on normal characters (for example , it replaces "a" with "b") .. i've tryed all the possible encodings but yet no result .. any ideeas ?