Hi folks.  I'm running into a problem translating single quotes that I'm
hoping someone can help with.

In my CMS, content is encoded using htmlentities() before it is stored
in the database.  During publishing the encoded content from the db is
decoded before being written to the file.

However, for some reason single quotes (') are not being decoded
even though I'm using ENT_QUOTES.

Here are the functions:

function CMS_encode_html($html, $mode = 1)
{
        $html = str_replace($this->CMS_base_path,'/',$html);
        
        if ($mode == 1) {
                $html = htmlentities($html, ENT_QUOTES);
        } else {
                $trans_tbl = get_html_translation_table(HTML_ENTITIES,
ENT_QUOTES);
                $trans_tbl = array_flip($trans_tbl);
                $html = strtr($html, $trans_tbl);
        }
        return $html;
}

function SITE_decode_html($html)
{
        $trans_tbl = get_html_translation_table(HTML_ENTITIES,
ENT_QUOTES);
        $trans_tbl = array_flip($trans_tbl);
        $html = strtr($html, $trans_tbl);
        return $html;
}

Can anyone give me an idea as to why single quotes are not being
translated here?

I've fixed the problem simply by adding a str_replace() call to replace
all instances of ' with ' before returning the $html variable in
the decode function, but I really want to know why it's not working
properly.

Can anyone give me any ideas?

Cheers and TIA.

Pablo

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to