Reputation: 1833
I have a string that is stored in a tsql database(the expected string should display "a'string"
) but when I load it into my web browser I see "a'string"
same for all the special characters. The encoding is also saved as "a'string"
in the database.
I'm under the belief that my webpage's encoding is different than my db and this is what is causing the issue.
after running:
SELECT SERVERPROPERTY('Collation')
I see that the encoding is set to SQL_Latin1_General_CP1_CI_AS
and I have placed
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
in the head of my layout page.
I'm very confident that this is not the correct type, and was looking for some guidance as to how to solve this.
I cannot change anything about my SQL server, this is very locked down and read-only.
Upvotes: 0
Views: 2833
Reputation: 2290
This is not a problem of your SQL, most likely your server side code is converting special char to HTML entities using htmlentities. Not sure what language you are using, PHP for example, you can use html_entity_decode to display it correctly.
$str = "a'string";
echo htmlentities($str,ENT_QUOTES); //OUTPUT a'string
echo html_entity_decode(htmlentities($str,ENT_QUOTES),ENT_QUOTES); //OUTPUT a'string
Upvotes: 2
Reputation: 3030
Your database is capable of double-byte, that's not the problem. It appears that you're running into a security measure -- the single-quote being escaped/decoded so that it doesn't go into the database execution as a single quote (which is a string delimiter for SQL).
why "'" is not getting converted to single quotes while using server.htmldecode()?
Upvotes: 0