I'm using AJAX in my site and Latin 1 characters which is indeed a problem. The solution I found was to convert accented character in html entities but i don't know how.
I'd like to transform ó, for example, in ó
I tried to use htmlentities("ó") but it printed ó
. I don't know what to do anymore
I'm using ZF and JQuery. My site uses a form to record some data. To insert this data I use
$data = array(
'reg_creditorid' => $this->_request->getParam('creditor'),
'reg_debtorid' => $this->_request->getParam('debtor'),
'reg_reason' => htmlentities($this->_request->getParam('reason')),
'reg_value' => str_replace(',', '.', $this->_request->getParam('value')),
'reg_date' => date('Y-m-d')
);
$this->registries->insert($data);
When I tried to type ó in the text input I noticed that when I used getParam, it got ó
instead of ó
I created a test project, with nothing (no ZF, no jQuery, no MVC, nothing). I coded echo htmlentities('ó');
and it printed ó
. What could it be, then?
Pick one character encoding (UTF-8 is a better idea than ISO-8859-1) and stick to it.
Whatever htmlentities is doing, it is treating the data as a different encoding to whatever it is actually using.
将您用于页面的字符集传递给htmlentities函数:
htmlentities("ó",ENT_NOQUOTES,'ISO-8859-1')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.