[英]How to transform accented characters in html?
我在我的網站中使用AJAX和拉丁1字符,這確實是一個問題。 我發現的解決方案是在html實體中轉換帶重音符號的字符,但我不知道如何。
我想轉換ó,例如,以ó
我嘗試使用htmlentities(“ó”),但它打印了ó
。 我不知道該怎么辦
我正在使用ZF和JQuery。 我的網站使用一種表格來記錄一些數據。 要插入此數據,我使用
$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);
當我嘗試在文本輸入中鍵入ó時 ,我注意到當我使用getParam時,它得到了ó
而不是ó
我創建了一個測試項目,什么也沒有(沒有ZF,沒有jQuery,沒有MVC,什么也沒有)。 我編碼echo htmlentities('ó');
並打印ó
。 那會是什么呢?
選擇一種字符編碼(UTF-8比ISO-8859-1更好),並堅持使用。
無論htmlentities在做什么,它都將數據視為與實際使用的數據不同的編碼。
將您用於頁面的字符集傳遞給htmlentities函數:
htmlentities("ó",ENT_NOQUOTES,'ISO-8859-1')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.