html-entities

Ruby json gem is encoding html entities

大憨熊 提交于 2019-12-08 12:24:41
问题 I make a hash called timeOffsets in my code @timeOffsets = Hash.new total=0 @sections.each do |i| @timeOffsets[i.shortcode] = total total+=i.length end And I render it in Javascript using to_json, : timeOffsets=<%=@timeOffsets.to_json%>; but I get it with the HTML entities encoded: timeOffsets={"Introduction_to_Lists":0,"Removing_elements":693,"Joining__join_":1490}; How do I stop it from encoding the HTML entities? 回答1: timeOffsets=<%=raw @timeOffsets.to_json%> Use the raw view helper. 来源:

Convert HTML entities and special characters to UTF8 text in PHP

只谈情不闲聊 提交于 2019-12-08 05:57:43
问题 There are a lot of questions and documentation about converting HTML entities and special characters to UTF8 text in PHP. And also there is the PHP documentation itself, such as this htmlspecialchars_decode() and this html_entity_decode(). However, I could not find any function/solution that clearly describes how to convert any HTML characters and special entities to UTF-8 text. All of them state something like "if you want to do this, then do that", etc. But no solution ever states " to have

AngularJS: escaped characters in model assigned to input value

时光毁灭记忆、已成空白 提交于 2019-12-08 04:16:07
问题 I have such problem: on the server I read data and use htmlentities on it, so my letters like ä are changed to the ä and I want to show this as a value of the input tag, e.g. <input type="text" ng-model="data.name" /> but here instead of ä character I see escaped version of it. If I show this value using e.g. <span ng-bind-html="data.name"></span> everything works. What can I do to make it works properly? 来源: https://stackoverflow.com/questions/25241645/angularjs-escaped-characters-in-model

Can I use htmlentities() in an SQL query?

非 Y 不嫁゛ 提交于 2019-12-07 17:29:33
问题 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

Java JTextPane HTML Editor UTF-8 characters encoding

浪子不回头ぞ 提交于 2019-12-07 15:27:19
问题 I'm using JTextPane as simple html editor. jtp=new JTextPane(); jtp.setContentType("text/html;charset=UTF-8"); jtp.setEditorKit(new HTMLEditorKit()); When I call jtp.getText() I get nice html code with all special chars escaped. But I don't want escape national characters (polish) but only special html chars like &, <, > When I enter in editor <foo>ą ś & I get <foo>ą ś & but I would like get <foo>ą ś & How it is possile? 回答1: That's not possible, unfortunately. There's a flaw inside javax

IE8 is not rendering some of the HTML name entities

六月ゝ 毕业季﹏ 提交于 2019-12-07 12:01:26
问题 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

htmlentities equivalent in JSP?

淺唱寂寞╮ 提交于 2019-12-07 11:42:04
问题 I'm a php guy, but I have to do some small project in JSP. I'm wondering if there's an equivalent to htmlentities function (of php) in JSP. 回答1: public static String stringToHTMLString(String string) { StringBuffer sb = new StringBuffer(string.length()); // true if last char was blank boolean lastWasBlankChar = false; int len = string.length(); char c; for (int i = 0; i < len; i++) { c = string.charAt(i); if (c == ' ') { // blank gets extra work, // this solves the problem you get if you

PHP htmlentities allow <b> and <i> only

▼魔方 西西 提交于 2019-12-07 11:28:13
问题 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. 回答1: It's pretty easy <?php $string = htmlentities($text); $string = str_replace(array("<i>", "<b>", "</i>", "</b>"), array("<i>", "<b>", "</i>", "</b>"), $string); 回答2: I use a helper function: # Sanitizer function - removes forbidden tags, including script tags function strip_tags_attributes( $str, $allowedTags = array('

PHP $_POST doesn't take accents

依然范特西╮ 提交于 2019-12-07 10:04:14
问题 This question is solved, check my answer to see the solution I'm trying to add to my DB a text with accented letters through an html form that submits with POST to a PHP page, the problem is that accented letters are converted to unreadable characters. I have this form: <form action="page.php" method="POST"> <input type="textarea" id="text1" name="text1" /> <input type="submit" value="Send" /> </form> And then, in page.php: echo $_POST['text1']; The problem is that if i input àèìòù in my

How to get char from HTML character code?

[亡魂溺海] 提交于 2019-12-07 05:43:54
问题 How can I convert the HTML entities € ► ♠ to their actual characters € ► ♠ using JavaScript? 回答1: An example would be: alert(String.fromCharCode(8364)); Where 8364 is the number of the HTML entity. To replace a full body of text automatically then you will need to use this regular expression replacement example: "The price of milk is now €100000.".replace(/&#(\d{0,4});/g, function(fullStr, str) { return String.fromCharCode(str); }); The magic happens here: replace(/&#(\d{1,4});/g, function