-1

I want to store in a SQL Server database a note of a user. Sometimes they are using characters like €. But when the note is shown on the page you see this: "â, .┐ ".

function MyFunction(){
  var sNote = $("#usernote").val();
  ...
}

How can you keep the right character in the database?

user1531040
  • 2,143
  • 6
  • 28
  • 48
  • 4
    Use UTF-8 encoding on the front-end and on the back-end too. That way you can store whatever character you want safely. – KristofMorva May 15 '14 at 08:43
  • 1
    How many times does this question have to be answered before people search? http://stackoverflow.com/a/21914278/692942 – user692942 May 15 '14 at 10:01
  • possible duplicate of [Convert UTF-8 String Classic ASP to SQL Database](http://stackoverflow.com/questions/21866225/convert-utf-8-string-classic-asp-to-sql-database) – user692942 May 15 '14 at 22:21
  • This was, what I needed [Wrong charset in ASP classic loaded via AJAX][1] [1]: http://stackoverflow.com/questions/9716693/wrong-charset-in-asp-classic-loaded-via-ajax – user1531040 May 20 '14 at 08:18

1 Answers1

1

If you still want to stick to Windows-1252 encoding, you could map commonly used special characters like the Euro Sign etc. to HTML Entities for Output on the screen.

Input form data that might contain those characters you might have treated as Unicode input though, depending on what kind of special characters you want to be able to handle...

However many of the typical characters like € or ä, ß are still readable via single byte, if you assume a specific ascii code page.

Here is a character table that shows the differences between DOS CP-437 (US), DOS CP-850 (GERMAN) and WIN-1252 plus the HTML entity equivalents (ASCII Code Table Map), which you should always use for HTML output, like I just did in this comment.

  • yuck yuck yuck...not great advice. Hey instead of handling encoding properly use this lazy approach. Instead of having readable properly encoded source lets start putting `#` html equivalents everywhere, because *"you should always use for html output"*. Nope wrong again. – user692942 May 18 '14 at 23:05