Questions tagged [html-encode]

Anything related to encoding or decoding HTML entities.

Specifying the document's character encoding

There are several ways to specify which character encoding is used in the document. First, the web server can include the character encoding or charset in the Hypertext Transfer Protocol () Content-Type header, which would typically look like this:

Content-Type: text/html; charset=ISO-8859-1

This method gives the HTTP server a convenient way to alter document's encoding according to content negotiation; certain HTTP server software can do it, for example Apache with the module mod_charset_lite.

For HTML it is possible to include this information inside the head element near the top of the document:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

also allows the following syntax to mean exactly the same:

<meta charset="utf-8">

Character encoding in HTML: http://en.wikipedia.org/wiki/Character_encodings_in_HTML

631 questions
58
votes
0 answers

how do you do html encode using javascript?

Possible Duplicate: JavaScript/jQuery HTML Encoding I have html tags need to be encoded. test I need to encode it to : <b>test</b> I am using escape, but it doesn't work. document.write(escape("test")); the result I…
qinking126
  • 11,385
  • 25
  • 74
  • 124
51
votes
5 answers

What is the difference between AntiXss.HtmlEncode and HttpUtility.HtmlEncode?

I just ran across a question with an answer suggesting the AntiXss library to avoid cross site scripting. Sounded interesting, reading the msdn blog, it appears to just provide an HtmlEncode() method. But I already use HttpUtility.HtmlEncode(). Why…
g .
  • 8,110
  • 5
  • 38
  • 48
47
votes
7 answers

C# HTMLDecode without System.Web possible?

I know there are different methods in the System.Web namespace for decoding html entities (such as "%20" for space). I'm building a Winforms application however, but needs to deal with html encoded strings. Basically I have the iTunes Library XML…
miccet
  • 1,870
  • 3
  • 19
  • 26
46
votes
4 answers

Html encode in PHP

What is the easiest way to Html encode in PHP?
Mathias F
  • 15,906
  • 22
  • 89
  • 159
45
votes
5 answers

HTML.Encode but preserve line breaks

I take user input into a text area, store it and eventually display it back to the user. In my View (Razor) I want to do something like this... @Message.Replace("\n", "
") This doesn't work because Razor Html Encodes by default. This is great…
BZink
  • 7,687
  • 10
  • 37
  • 55
45
votes
6 answers

Converting HTML entities to Unicode Characters in C#

I found similar questions and answers for Python and Javascript, but not for C# or any other WinRT compatible language. The reason I think I need it, is because I'm displaying text I get from websites in a Windows 8 store app. E.g. é should…
Remy
  • 12,555
  • 14
  • 64
  • 104
42
votes
5 answers

How do I bypass the HTML encoding when using Html.ActionLink in Mvc?

Whenever I use Html.ActionLink it always Html encodes my display string. For instance I want my link to look like this: More… it outputs like this: More… &hellip is "..." incase you were…
Micah
  • 111,873
  • 86
  • 233
  • 325
40
votes
11 answers

Html inside XML. Should I use CDATA or encode the HTML

I am using XML to share HTML content. AFAIK, I could embed the HTML either by: Encoding it: I don't know if it is completely safe to use. And I would have to decode it again. Use CDATA sections: I could still have problems if the content contains…
alberto
  • 553
  • 1
  • 4
  • 7
39
votes
4 answers

How to make Jade stop HTML encoding element attributes, and produce a literal string value?

UPDATE Jade v0.24.0 fixes this with a != syntax for attributes. option(value!='<%= id %>') I'm trying to build an
Derick Bailey
  • 72,004
  • 22
  • 206
  • 219
35
votes
2 answers

HTML Encoding Strings - ASP.NET Web Forms VS Razor View Engine

I'm not quite sure how this works yet... trying to find documentation. In my existing app I've got two different ways of rendering strings in my View <%: model.something %> <%= model.something %> The first one is html encoded, and the…
Chase Florell
  • 46,378
  • 57
  • 186
  • 376
34
votes
8 answers

How do I escape some html in javascript?

Given the text This is some text I want to write it to my page so that it shows up like this: This is some text and not like this This is some text using escape("This is some text") gives me this lovely gem in…
Micah
  • 111,873
  • 86
  • 233
  • 325
33
votes
7 answers

Is there a JDK class to do HTML encoding (but not URL encoding)?

I am of course familiar with the java.net.URLEncoder and java.net.URLDecoder classes. However, I only need HTML-style encoding. (I don't want ' ' replaced with '+', etc). I am not aware of any JDK built in class that will do just HTML encoding. …
Eddie
  • 53,828
  • 22
  • 125
  • 145
32
votes
4 answers

HTML encode user input when storing or when displaying

Simple question that keeps bugging me. Should I HTML encode user input right away and store the encoded contents in the database, or should I store the raw values and HTML encode when displaying? Storing encoded data greatly reduces the risk of a…
Mark S. Rasmussen
  • 34,696
  • 4
  • 39
  • 58
31
votes
2 answers

PHP html decoding help - converting: A 'quote' is bold

I need to convert a string like this: A 'quote' is bold into: A 'quote' is bold html_entity_decode() did not work.
tzmatt7447
  • 2,329
  • 9
  • 24
  • 31
31
votes
3 answers

How to display HTML stored in a database from an ASP.NET MVC view?

I have HTML code edited by FCKEditor stored in a database and would like to display (well render) it onto a view. So, for instance, something stored as: <>pre<>This is some sample text<>pre</> Will be displayed to the user…
Jedidja
  • 16,610
  • 17
  • 73
  • 112
1
2
3
42 43