html-entities

Error Parsing /page.xhtml: Error Traced[line: 42] The entity “nbsp” was referenced, but not declared

久未见 提交于 2019-12-17 07:13:09
问题 I'd like to use non breaking spaces in my JSF page. I know, in plain HTML I could use   for this and this works fine. However, when I put those   in a Facelets page, then it errors as follows: Error Parsing /page.xhtml: Error Traced[line: 42] The entity "nbsp" was referenced, but not declared. How is this caused and how can I solve it? 回答1: Facelets is a XML based view technology. XML has only five predefined entities. The   is not among them. It works only when used in plain HTML or in

printing “<html>” using html

可紊 提交于 2019-12-17 06:16:27
问题 How do I print the "html" tag, including '<' and '>'? How can I do this for any tag, without using text areas and Javascript? 回答1: Use HTML character references: <html> Should output <html> 回答2: Try doing: <html> 回答3: Special characters in HTML, such as '<', '>', '"' and '&' can be printed using the following format: &name; where name would be replaced by a character name. The most common would then be < = < (less than) > = > (greater than) & = & (ampersand) " = " (double quote) So to write

How do I decode HTML entities in swift?

老子叫甜甜 提交于 2019-12-16 19:32:07
问题 I am pulling a JSON file from a site and one of the strings received is: The Weeknd ‘King Of The Fall’ [Video Premiere] | @TheWeeknd | #SoPhi How can I convert things like &#8216 into the correct characters? I've made a Xcode Playground to demonstrate it: import UIKit var error: NSError? let blogUrl: NSURL = NSURL.URLWithString("http://sophisticatedignorance.net/api/get_recent_summary/") let jsonData = NSData(contentsOfURL: blogUrl) let dataDictionary = NSJSONSerialization.JSONObjectWithData

Native JavaScript or ES6 way to encode and decode HTML entities?

天涯浪子 提交于 2019-12-14 00:43:03
问题 Is there a native way to encode or decode HTML entities using JavaScript or ES6? For example, < would be encoded as < . There are libraries like html-entities for Node.js but it feels like there should be something built into JavaScript that already handles this common need. 回答1: There is no native function in the JavaScript API that convert ASCII characters to their "html-entities" equivalent. Here is a beginning of a solution and an easy trick that you may like 回答2: A nice function using

Unwanted replacement of html entities by BeautifulSoup

末鹿安然 提交于 2019-12-13 17:15:50
问题 I have some html containing mml that I am generating from Word documents using MathType. I have a python script that uses BeautifulSoup to prettify it, but the problem is it takes something like ∠ and turns it into the actual byte sequence 0xE2 0x88 0xA0 which is the ∠ symbol. This is a problem because 0xE2 0x88 0xA0 won't display as ∠ in the browser. Instead the browser interprets it as a series of latin characters. This is happening with all the math entities as well, such as Δ ∠ − &plus;..

In php, Prepare string and create XML/RSS Feed

送分小仙女□ 提交于 2019-12-13 16:32:55
问题 I want to create my own RSS/XML feed. I fetch data from the database to display, but keep getting invalid character errors. If the string has an ampersand or other strange characters in it, the XML will be invalid. I tried using urlencode and htmlentities, but these don't capture all possible characters which need to be escaped. Does anyone know of a PHP function which will prepare a string for XML output? 回答1: htmlspecialchars should be enough. But don't forget to set the 3rd parameter

Problems using extended escape mode for jsoup output

删除回忆录丶 提交于 2019-12-13 14:35:46
问题 I need to transform a HTML file, by removing certain tags from the file. To do this I have something like this - import org.jsoup.Jsoup; import org.jsoup.helper.Validate; import org.jsoup.nodes.Document; import org.jsoup.nodes.Entities; import org.jsoup.nodes.Entities.EscapeMode; import java.io.IOException; import java.io.File; import java.util.*; public class TestJsoup { public static void main(String[] args) throws IOException { Validate.isTrue(args.length == 1, "usage: supply url to fetch"

to replace “ ” with  

北城以北 提交于 2019-12-13 08:49:00
问题 this is my javascript code: mystring = "this is sample"; nestring = mystring.replace(/ /g," "); I need nestring ouput "this is sample". but with the code above, nestring = "this is sample" how can I replace space( ) with &nbsp(   )? Many thanks! re: I embed svg in html. But ie, chrome do not support xml:space=preserve, firefox does. By replace " " with &nbsp, multiple " " will not condense to one " ". 回答1: You could use the Unicode: nestring = mystring.replace(/ /g, "\u00a0"); But your

PHP html_entity_decode Doesn't Decode Entity as Expected?

跟風遠走 提交于 2019-12-13 07:47:59
问题 In the following code: $string1 = "function doesn&apos;t work as expected"; $string2 = html_entity_decode($string1); $string2 still contains: &apos; ...after the call to html_entity_decode(). I've checked other SO threads on this topic, but haven't yet found the answer. What am I missing? 回答1: The default flags for html_entity_decode do not include single quotes. Try updating your flags argument to include ENT_QUOTES and ENT_HTML5 : $string1 = "function doesn&apos;t work as expected"; echo

Apply htmlentities to stripped tags

只谈情不闲聊 提交于 2019-12-13 01:22:54
问题 Researched links: How do you apply htmlentities selectively? and PHP function to strip tags, except a list of whitelisted tags and attributes They are close but not as expected. What have I tried? <?php define('CHARSET', 'UTF-8'); define('REPLACE_FLAGS', ENT_HTML5); function htmlcleaned($string) { $string = htmlentities($string); return str_replace( array("<i>", "<b>", "</i>", "</b>", "<p>", "</p>"), array("<i>", "<b>", "</i>", "</b>", "<p>", "</p>"), $string); } echo htmlcleaned("<p>How are