views:

21

answers:

1

Hi-- I'm trying to parse a string from a French text, and I'm using both htmlspecialchars and html_entity_decode-- but certain characters aren't getting properly converted.

Any ideas?

Here's the code:

html_entity_decode(htmlspecialchars_decode($this->string($tstring))); // returned from web service

In particular, the entity that isn't decoding is this one:

'

Thanks for any help!

+2  A: 

You need to pass ENT_QUOTES as the quote_style parameter:

http://php.net/manual/en/function.html-entity-decode.php

Otherwise, html_entity_decode() defaults to ENT_COMPAT which converts double-quote characters but doesn't touch single-quote characters (which is what ' is - a single quote).

$result = html_entity_decode($input_string, ENT_QUOTES);
Amber
thanks amber! missed that parameter.
julio