Problem writing non-english characters

  • Thread starter Thread starter barry
  • Start date Start date
B

barry

Hello

When writing the following string

Ecole élémentaire privée Notre-Dame

i get this

Ecole élémentaire privée Notre-Dame


I have used

TextWriter tw = new StreamWriter("AAA.txt", false, UTFEncoding(true);
tw.Write("Ecole élémentaire privée Notre-Dame");
tw.Close();

Can someone help me with this.

Regards
barry
 
When writing the following string

Ecole élémentaire privée Notre-Dame

i get this

Ecole élémentaire privée Notre-Dame

I have used

TextWriter tw = new StreamWriter("AAA.txt", false, UTFEncoding(true);
tw.Write("Ecole élémentaire privée Notre-Dame");
tw.Close();

A few things:
1) What are you using to look at your file, and what encoding is it
expecting?
2) Do you actually have the string literal in there? If so, it will
depend on which encoding the compiler is using too. I normally try to
stick to ASCII in my C# code, using Unicode escape sequences (\uxxxx)
for non-ASCII characters
3) I doubt that that's your actual code, as I expect you've got a
"new" in there for the UTFEncoding - which means there could be other
changes too.
4) It's generally a good idea to use a "using" statement rather than
manually closing TextWriters
5) File.WriteAllText is a simpler way of doing this :)

The actual encoding issue is very likely to just be whatever you're
using to read the file though.

Jon
 
Back
Top