HTML is stored in the DB. £ sign is stored as £ and renders correctly in 1252 however when I change the page encoding to utf-8 renders incorrectly ?
I know its a simple issue.. ?
HTML is stored in the DB. £ sign is stored as £ and renders correctly in 1252 however when I change the page encoding to utf-8 renders incorrectly ?
I know its a simple issue.. ?
If your database encoding is not UTF-8, or if the application does not retrieve data from the database as UTF-8, data stored in the database will not render correctly. What is the database, what is your application platform?
You need to ensure that both the DB server and connection to it are UTF8 enabled. What DB and web server are you using?
You could replace with:
£ or £
http://www.w3schools.com/tags/ref%5Fentities.asp
Also make sure that you have set the charset and encoding to utf-8.
This Stack Overflow thread describes how to use UTF-8 + MySQL + PHP: http://stackoverflow.com/questions/1085093/strategy-for-supporting-unicode-multi-language-in-php5/1085171#1085171
Also, make sure you’re using the correct htmlentities()
parameters when working with UTF-8 strings.
Update: I’ve just noticed you updated your post (tags) to show that you’re using ASP (not PHP), but I guess the answer still goes. Make sure the database tables and fields as well as the connection to that database are set to UTF-8, and make sure you’re correctly handling UTF-8 strings in your application.
I'm not so sure that classic ASP uses UTF8 as its default string type (like .net does), so you may be able to simply change the page to ISO-8859-1 and it will work.
What collation sequence is your SQL Server using for the column, and what code page is in use on the system? It will convert the incoming data to something that can be stored in that character set, and that might not be valid for what you want to get back. My company's product accidentally translated 'ü' into '÷' until we straightened this out.
What needs to be done to use UTF-8 properly in ASP.
<%@ codepage=65001 %>
Response.CharSet = "UTF-8"
That said I would strongly recommend against storing HTML in a DB unless you really building some kind of CMS and/or have some rigourous vetting procedures in place.
My guess is you've forgotten to do one of the last two bullet points.
have you saved the chars as unicode in the DB ?
when inserting unicode data in a nvarchar fields always preceed the string with N as in insert into table (stringfieldname) values (N'data to be inserted')
which will ensure the correct storing of the data ...