tags:

views:

73

answers:

2

I have cute editor in my web site with C#. I save data into a SQL Server database and I display that data in label. Everything's ok.

After I publish my site to a server and insert data it displays in the label like "????????????????". Why?

A: 

Without any more detail, I can only but speculate.

This look like an encoding problem. When the encoding isn't specified, the browser defaults back to the encoding specified in the HTTP header sent by the server. Make sure that you are reading and storing using the same encoding.

Ensure that you specify the charset using the meta tag to something like

<meta charset="utf-8" />

Also, you might consider using the NVARCHAR data type instead of the regular VARCHAR for storing unicode character in Sql Server if you are using a unicode charset.

Pierre-Alain Vigeant
A: 

It sounds like an encoding issue. A similar issue in older versions of Notepad if you type 'this app can break' because it incorrectly guesses the encoding as Japanese.

The solution is to be aware of what encoding your text is stored in and to always read and write the data using the correct encoding. This means:

  • handling input text correctly in your server-side code
  • storing it correctly in the database
  • displaying it correctly to the end-user

If any one of the these steps fails, you could end up with unreadable incorrectly encoded text.

Mark Byers