convert &ldquo and &rdquo to double quotes

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
deserteagle369
Posts: 94
Joined: Wed Feb 29, 2012 2:00 am

convert &ldquo and &rdquo to double quotes

Post 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
Eagle
Life is a journey.
mkoch227
Posts: 666
Joined: Wed Jul 04, 2012 3:37 pm

Re: convert &ldquo and &rdquo to double quotes

Post 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 <
Mike, Lead Developer of Image HESK: A surprisingly simple, user-friendly and FREE help desk software with integrated knowledgebase.
deserteagle369
Posts: 94
Joined: Wed Feb 29, 2012 2:00 am

Re: convert &ldquo and &rdquo to double quotes

Post 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?
Eagle
Life is a journey.
Post Reply