views:

240

answers:

3

I have a winForm application that generates an .aspx file based on the user input in the application. The problem happens when a user enters the French letters like "é", "à", "è", "â", "ù", "ô", "ê" and "ç". It is supposed to look like a simple text on the page but it doesn't. Any ideas?

A: 

What does the text look like? Have you ensured the encoding type supports extended characters?

Ian Suttle
+3  A: 

Assuming you want the characters to be displayed with the accents, circumflexes, etc. try the following:

Add the following to the <head> of each (generated) page:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Make sure that the .aspx files themselves are saved as UTF-8 files.

Note: I'm assuming here that an .aspx file is somewhat similar to a .jsp file. If that assumption is false, you should probably ignore this advice.

Don
I was constantly trying that meta tag with charset=UTF-8, but haven't set the encoding of my textWritter, like you and the others suggest. So I think that TextWriter tw = new StreamWriter("Default.aspx", false, Encoding.UTF8); will do the trick.
Ivan
+1  A: 

How are you creating the .aspx file? If you're using a TextWriter, check the Encoding. If you're trying to write an array of bytes to a FileStream, be sure you use the right encoding when converting from String to Byte[]. UTF-8 is usually the best encoding for the web.

Robert Lewis