Page 1 of 1

convert &ldquo and &rdquo to double quotes

Posted: Fri Dec 30, 2016 4:37 am
by deserteagle369
Script URL:
Version of script: 2.41
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:

Write your message below:
I want to pup up a suggest article list when admin input new ticket, I did this:
1. some js code to trigger autocomplete function on subject field
2. some php code to return related kb articles based on subject
3. load the article content to the msg body when admin select from the pop up suggest article list
It work well but some special characters show in the msg body, like &ldquo, &rdquo, it should be converted to double quotes " and ".

I tried using $txt=htmlspecialchars_decode($txt) but it can not work.

any suggestion?

thanks

Re: convert &ldquo and &rdquo to double quotes

Posted: Fri Dec 30, 2016 6:12 pm
by mkoch227
&ldquo (“) and &rdquo (”) are variants on the (more simple) &quot ("), but they are both handled natively in HTML, so I believe htmlspecialchars_decode does not handle ldquo and rdquo as it assumes that they aren't escaped. html_entity_decode, on the other hand, does handle encoding and decoding “ and ”. So you have two options:
  1. Use html_entity_decode
  2. Replace “ and ” with just " and then use htmlspecialchars_decode
html_entity_decode with &ldquo;, &rdquo;, >, and <

Re: convert &ldquo and &rdquo to double quotes

Posted: Tue Jan 10, 2017 2:26 am
by deserteagle369
hi, mkoch227

thanks for reply, but html_entity_decode can not work, it remove all the contents after subject ( I want article.subject + "==>" + article.content).

I made my customize suggest article php based on suggest_article.php, almost the same, the difference is my codes return Json data not echo the article content to the webpage.

The problem only happen for the SBC case quotes, all such characters input will be convert to &ldquo, &rdquo store in database, when pull it out and echo to the webpage, it will automatically display as double quotes correctly, but not for return json data.

any suggestion?