html-entities

PHP htmlentities() without converting html tags

痴心易碎 提交于 2019-12-07 05:40:53
问题 I've found a few posts which refer to the problem, but none of them fully resolve it. I need the function which will output the content converting all special characters in the way the htmlentities() would, but preserving all html tags. I've tried many different approaches, but as I've mentioned above - none of them works as expected. I was wondering whether there would be a way of doing it using PHP class DomDocument. I've tried to do it using the following: $objDom = new DOMDocument('1.0',

How can I use PHP's preg_replace function to convert Unicode code points to actual characters/HTML entities?

戏子无情 提交于 2019-12-06 11:55:47
I want to convert a set of Unicode code points in string format to actual characters and/or HTML entities (either result is fine). For example, if I have the following string assignment: $str = '\u304a\u306f\u3088\u3046'; I want to use the preg_replace function to convert those Unicode code points to actual characters and/or HTML entities. As per other Stack Overflow posts I saw for similar issues, I first attempted the following: $str = '\u304a\u306f\u3088\u3046'; $str2 = preg_replace('/\u[0-9a-f]+/', '&#x$1;', $str); However, whenever I attempt to do this, I get the following PHP error:

how to encode single quotes

你离开我真会死。 提交于 2019-12-06 07:49:39
问题 I want to know how i use htmlentities •' for ' in my code ? How to escape single quote hows apostrophe work in IE while($row = pg_fetch_array($result)) { if($row[3]=="") { $vmobj_Array[$i]=$row[0]."***".$row[1]."***".$row[2]; } else { $vmobj_Array[$i]=$row[0].' ( '.$row[3].' )'."***".$row[1]."***".$row[2]; } $i++; } 回答1: I think every question should have an answer, so I'm posting here as well. Feel free to accept the answer someone else posted there just now. htmlentities($str, ENT_QUOTES);

Getting Html Entities for all major currencies

痴心易碎 提交于 2019-12-06 07:48:41
问题 Currently i am trying to look for the html entities for all the major currencies , i can easily get for USD , EURO , CAD, AUD and few more but i am having hard time getting entities for all other countries i have Bulgarian Lev (лв) , Chinese Renminbi (¥), Russian Ruble (руб), U.A. Emirates Dirhams (د.إ) Everytime i enter them in my dropdown they are coming as ? sign , so is there any way around it and yes i am using correct meta charset, just trying to get html entities for them Thanks 回答1:

Jsoup having problems with special HTML symbols, ‘ — etc

做~自己de王妃 提交于 2019-12-06 03:32:05
问题 I have some HTML (String) that I am putting through Jsoup just so I can add something to all href and src attributes, that works fine. However, I'm noticing that for some special HTML characters, Jsoup is converting them from say “ to the actual character “ . I output the value before and after and I see that change. Before: THIS — IS A “TEST”. 5 > 4. trademark: ™ After: THIS — IS A “TEST”. 5 > 4. trademark: ? What the heck is going on? I was specifically converting those special

How to convert & characters to HTML characters?

不羁的心 提交于 2019-12-06 02:51:48
<?php echo "Hello World!"; ?> should be: <?php echo "Hello World!"; ?> How do I do that in PHP? You need one of these: html_entity_decode() htmlspecialchars_decode() html_entity_decode() in PHP Manual htmlspecialchars_decode() in PHP Manual The main difference is that html_entity_decode() will translate all the HTML entities in your string ( < becomes < , á becomes á , etc.) while html_specialchars_decode() only translates some special HTML entities: The converted entities are: & , " (when ENT_NOQUOTES is not set), ' (when ENT_QUOTES is set), < and > . htmlspecialchars_decode() Are you looking

Can I use htmlentities() in an SQL query?

浪子不回头ぞ 提交于 2019-12-06 00:19:01
Much thanks for the discussion my original question generated. I took Jay's suggestion to use bind_param(), but there is something I don't understand about it that may be giving me the Server Error: "The website encountered an error while retrieving...". I don't know what the parameter 'sssd' that came with the example means. Any suggestions as to what is generating the Server Error are much appreciated. <?php $mysqli = new mysqli('my-database-address', 'my-username', 'my-password', 'my-database-name'); f (mysqli_connect_errno()) { printf("Connect failed: %s\n", mysqli_connect_error()); exit()

IE8 is not rendering some of the HTML name entities

白昼怎懂夜的黑 提交于 2019-12-05 21:14:23
Some HTML name entities are not rendering in IE8 and instead I can see the not rendered HTML entity! For example &scedil; or &inodot; . I found a solution to use HTML number entities such as ş instead of &scedil; . I was wondering if anyone knows about the reason of this issue and if there is a way to see &scedil; or &inodot; or similar entities correctly in IE8? Here is my code on jsfiddle: (If you copy this code to a HTML file, it will not render in IE8) http://jsfiddle.net/7uBrd/ <HTML lang="TR"> <HEAD> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <TITLE>test</TITLE> <

Excel macro to convert HTML entities to text

旧巷老猫 提交于 2019-12-05 20:51:16
I have a huge Excel file that contains the result of an online survey. The person who built the survey messed up the formatting in several respects, and the mess-up I need to take care of first is converting HTML entities to regular text. From what I can see only two HTML entities are used, , and " but the document is over 12,000 rows so I cannot be sure there are no other HTML entities used... and if other HTML entities are used I want them converted to text as well. I have successfully made a macro to convert the two HTML entities I mentioned into text, but I don't know how to make the macro

PHP htmlentities allow <b> and <i> only

陌路散爱 提交于 2019-12-05 17:28:25
Using htmlentities() is there a way I can set to allow only <b> and <i> to convert into bold and italic text? I know there was one way of doing this, but i have forgotten. It's pretty easy <?php $string = htmlentities($text); $string = str_replace(array("<i>", "<b>", "</i>", "</b>"), array("<i>", "<b>", "</i>", "</b>"), $string); I use a helper function: # Sanitizer function - removes forbidden tags, including script tags function strip_tags_attributes( $str, $allowedTags = array('<a>','<b>','<blockquote>','<br>','<cite>','<code>','<del>','<div>','<em>','<ul>','<ol>','<li>','<dl>','<dt>','<dd>