Reputation: 13243
It seems when I add any special characters (like © and ®) to my database, it saves it including this character: Â
, so it saves it like this ©
It's popping up more and more now.
I can either think the database is doing this when I save the data (but it seems to be just currently happening), maybe it's because of the browser? Since I don't HTMLEncode the data when saving it to the database, but maybe not because I haven't been able to reproduce the issue myself personally, so wondering if someone else has had this same issue?
Do you think it's the web browser doing this? Maybe it's happening due to submitting the form via jQuery? What could be the culprit causing this?
Upvotes: 0
Views: 408
Reputation: 14810
That's caused by mis-matched encodings, typically one part of the application using iso-8859-1 and another part using utf-8
Check your database and individual table definitions, your web page content encoding, and your form encoding. Make sure they are consistently using the same encoding. We use utf-8 for everything, end-to-end.
We're using MySQL, not SQL Server, so I don't know particulars. For MySQL, our DDL files defining tables generally end with something like
SOMEDATA VARCHAR(100),
INDEX USER_ID
)
engine = InnoDB
default character set utf8
collate = utf8_general_ci
and in a common header that's included in all / generated pages
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
In the <form>
tag you can set the accept-charset explicitly
<form accept-charset="utf-8" (etc)>
See this not-entirely-relevant question here on SO
Upvotes: 1