FAQ Database Discussion Community


Code snippets and the web

javascript,html,angularjs,html-entities
It seems displaying code on the web involves: Encoding HTML entities Formatting A most basic workflow would thus seemingly be: Have a code snippet such as: <html> I'm a full page html snippet <html>. Encode it (using one of the many sites found by google) to e.g.: &#x3C;html&#x3E; I'm a...

Is it safe to unescape ampersand for user input?

php,html,html-entities,sanitization
After a few hours of bug searching, I found out the cause of one of my most annoying bugs. When users are typing out a message on my site, they can title it with plaintext and html entities. This means in some instances, users will type a title with common...

Is there any reason to use HTML entities over the characters themselves?

html,encoding,html-entities
For example, suppose I want to put an en dash in my page title, like this: Home – My Site Is there any reason to use &ndash; over just putting the character – in my HTML file?...

Strange Behaviour From htmlentities

php,html-entities
As I understand it, the html entity version of an apostrophe (single quote) is &#039;. That is how it is being encoded when I add data to my database. However when I try to search on the database I am getting a problem because the code I use gives the...

ngBindHtml different result than $sce.parseAsHtml in template that uses angularUI

angularjs,data-binding,html-entities
Edit: Solution found! See bottom of question for explanation. I have a directive sfNgFieldWrapper that contains a tooltip that I got from angularjUI ui-bootstrap. The text of the tooltip is set with tooltip="{{ttpText}}". The problem is that the text contains html entities and these entities are not translated to the...

SWIFT: +[CATransaction synchronize] called within transaction while decoding HTML entities

swift,html-entities,synchronize,catransaction
I am making an app that fetches JSON content of a blog. The titles of the blog articles are shown in tableView. The titles fetched were HTML encoded. So I decoded them using this code func configureCell(cell: UITableViewCell, atIndexPath indexPath: NSIndexPath) { let object = self.fetchedResultsController.objectAtIndexPath(indexPath) as NSManagedObject var encodedString...

Issue using html_entity_decode()

php,function,character-encoding,html-entities
Well I am building this crawler where i crawl article content that is not in english. However once i store the content to the database the html_entity_decode doesn't do the job correct, thus I am getting weird characters not the wanted ones. This is my line of code that I...

Add html entity by name with jQuery prop()

jquery,html,html-entities,prop
I'd like to add an ellipsis to an input element's placeholder attribute with jQuery prop() but instead of the intended … I get literal string &hellip;. How can I add html entities by name with jQuery prop()? $(document).ready(function(){ $('div#b input').prop('placeholder','Search&hellip;'); }); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script> <div id="a"><input type="text" placeholder="Search&hellip;" /></div><br /> <div...

How to remove   from a UTF-8 string?

php,utf-8,html-entities
My database is returning some strings like: This&nbsp;is&nbsp;a&nbsp;string This is a problem when the string is long enough and you have maximum width set: <p style="width:50px">This&nbsp;is&nbsp;a&nbsp;string</p> In order to get ride of &nbsp; entities I've tried to use the following filters without success: $new = preg_replace("/&nbsp;/i", " ", $str); $new...

How to add HTML entities in Angular select with ng-option

javascript,angularjs,select,html-entities,ng-options
My question is somehow related to this answer, although slightly different. What I would like to achieve is to get HTML entities parsed from a string passed to a select with ng-options. So given these data: $scope.myOptions = [{ text: '10.00 &euro;', val: 10 },{ text: '25.00 &euro;', val: 25...