Note that there are some explanatory texts on larger screens.

plurals
  1. POZend_Cache And UTF-8 Problem
    primarykey
    data
    text
    <p>I'm trying to save UTF-8 characters with Zend_Cache (like Ť, š etc) but Zend_Cache is messing them up and saves them as Å, ¾ and other weird characters.</p> <p>Here is a snippet of my code that saves the data to the cache (the UTF-8 characters are messed up only online, when I try it on my PC on localhost it works ok):</p> <pre><code>// cache the external data $data = array('nextRound' =&gt; $nextRound, 'nextMatches' =&gt; $nextMatches, 'leagueTable' =&gt; $leagueTable); $cache = Zend_Registry::get('cache'); $cache-&gt;save($data, 'externalData'); </code></pre> <p>Before I save the cached data, I purify it with HTMLPurifier and do some parsing with DOM, something like this:</p> <pre><code> // fetch the HTML from external server $html = file_get_contents('http://www.example.com/test.html'); // purify the HTML so we can load it with DOM include BASE_PATH . '/library/My/htmlpurifier-4.0.0-standalone/HTMLPurifier.standalone.php'; $config = HTMLPurifier_Config::createDefault(); $config-&gt;set('HTML.Doctype', 'XHTML 1.0 Strict'); $purifier = new HTMLPurifier($config); $html = $purifier-&gt;purify($html); $dom = new DOMDocument(); // hack to preserver UTF-8 characters $dom-&gt;loadHTML('&lt;?xml encoding="UTF-8"&gt;' . $html); $dom-&gt;preserveWhiteSpace = false; // some parsing here </code></pre> <p>Here is how I initialize Zend_Cache in the bootstrap file:</p> <pre><code>protected function _initCache() { $frontend= array('lifetime' =&gt; 7200, 'automatic_serialization' =&gt; true); $backend= array('cache_dir' =&gt; 'cache'); $this-&gt;cache = Zend_Cache::factory('core', 'File', $frontend, $backend); } </code></pre> <p>Any ideas? It works on localhost (where I have support for the foreign language used in the HTML) but not on the server.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload