C# - How to replace accented characters, i.e., "-É" with "- É"

Viewed 5373

I'm making a very simple Windows application using Visual Studio and C# that edits subtitles files for movies. I want a program that adds a space to dialog sentences when there isn't one. For example:

-Hey, what's up?

-Nothing much.

to

- Hey, what's up?

- Nothing much.

I used the toolbox to create an interface with just one button for selecting the correct file. This is the code I have for this button:

private void button1_Click(object sender, EventArgs e)
    {
        if (openFileDialog1.ShowDialog() == DialogResult.OK)
        {
            string text = File.ReadAllText(openFileDialog1.FileName, Encoding.GetEncoding("iso-8859-1"));
            text = text.Replace("-A", "- A");
            File.WriteAllText(openFileDialog1.FileName, text, Encoding.GetEncoding("iso-8859-1"));
        }
    }

What this does is basically replace "-A" with "- A", thus creating a space. This is the solution that I've come up with and I was planning to do this with every letter, including accented letters, such as À, Á, È, É, etc, etc.

This does not work. If I put text = text.Replace("-É", "- É"); the program does nothing.

What I want to know is how do I fix this.

Thank you for reading and if you have a better alternative for my application then please feel free to let me know.

2 Answers
Related