Character Encoding issues arrising from Content stored in a SQL server database.
by Michael Plant ~ October 23rd, 2008Just a quick note because I had a hard time hunting down the issue.
While in the process of doing a redesign for one of our clients I was changing the pages over to XHTML Transitional and was having some really weird character reference issues. It seems HTML4 handles the characters correctly but once i moved into the new XHTML declaration the quotes coming in form our SQL server were being converted to… who even knows?
They looked like some sort of mix between AE and Trademark special characters. But what made it even weirder was it was picking and choosing which ones to change and what it changed them too was different for the same Quotes. Now I have often know if the issues with using left quotes and right double quotes, etc. but had never had a problem with doing a string replace on the content prior to writing out the content in HTML.
I tried and Tried…
I racked my brain trying to do a string replace on many different variations of the same characters, I had Database access so I could see and even copy the characters in the table column but I could not get them to write correctly.
My boss and I both agreed it was a character issue and probably just needed set somewhere but either I was never tought this or I completely forgotten how to do this. I tried numerous searches on Google with no solution in sight. Finally today I came across the meta tag I was looking for:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
So for future reference I wanted to post this to make sure I have it available as I undoubtedly will run into this again. Since the whole purpose of my blog is to keep these types of issues and solutions close, so I don’t have to go searching through sites to find what I did, there it is; but this doesn’t give me the meaning of life, I was hoping one of you could enlighten me as to the issue and what caused it? While I consider myself and advanced developer I don’t know a lot about browsers or character references. So if you know what my problem was, tell ME!!


