Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You write HTML-encoded character, so I assume you want to convert characters into <a href="http://www.w3.org/TR/html4/charset.html#h-5.3.2" rel="nofollow noreferrer">HTML Entitites<sup><em>&shy;Ref</em></sup></a>. Those were introduced in HTML 2 (<a href="http://www.w3.org/MarkUp/html-spec/html-spec_9.html#SEC9.7.2" rel="nofollow noreferrer">ISO Latin 1 Character Entity Set</a>), as well as in HTML 3.2 (<a href="http://www.w3.org/TR/REC-html32#latin1" rel="nofollow noreferrer">Character Entities for ISO Latin-1</a>) and finally some more in HTML 4 (<a href="http://www.w3.org/TR/html4/sgml/entities.html" rel="nofollow noreferrer">Character entity references in HTML 4</a>).</p> <p>You have not shared which of those HTML versions you're using, so I suggest you take a look at the <a href="http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references" rel="nofollow noreferrer">List of XML and HTML character entity references<sup><em>&shy;Wikidpedia</em></sup></a> to locate the ones you'd like to replace.</p> <p>The PHP function that is related to these is called: <a href="http://php.net/htmlentities" rel="nofollow noreferrer"><code>htmlentities</code><sup>&shy;<em>Docs</em></sup></a>.</p> <p>Thanks to <a href="http://tools.ietf.org/html/rfc2616#section-14.17" rel="nofollow noreferrer">the content-type header in HTTP</a> and <a href="http://www.w3.org/TR/html4/charset.html#spec-char-encoding" rel="nofollow noreferrer">it's equivaltent in HTML</a>, it's not necessary to encode these characters as entities because you can just tell the browser which character set you're using. You only need to use entities in case the characters are not part of the encoding you use for the output/response.</p> <p>For those cases the <a href="http://php.net/htmlentities" rel="nofollow noreferrer"><code>htmlentities</code><sup>&shy;<em>Docs</em></sup></a> or the <a href="http://php.net/strtr" rel="nofollow noreferrer"><code>strtr</code><sup>&shy;<em>Docs</em></sup></a> functions can be used. As you have not specified which encoding are involved for the data and the target, no specific code example can by given, but only a general one:</p> <pre><code>echo htmlentities ($string, ENT_HTML401, $encoding = 'YOUR STRING ENCODING'); </code></pre> <p>The <a href="http://php.net/get_html_translation_table" rel="nofollow noreferrer"><code>ENT_HTML401</code> translation table<sup>&shy;<em>Docs</em></sup></a> will convert more than the characters you might have asked for.</p> <p>Instead of using the build-in translation tables, you can also create your own and do the conversion with the <a href="http://php.net/strtr" rel="nofollow noreferrer"><code>strtr</code><sup>&shy;<em>Docs</em></sup></a> function. This is also needed if the encoding of your data is not supported by <code>htmlentities</code>, for example for Adobe symbol fonts (See: <a href="https://stackoverflow.com/q/8240030/367456">How to convert Symbol font to standard utf8 HTML entity</a>). Or because you just want to run your own conversion (See <a href="https://stackoverflow.com/q/9736949/367456">How to substitute non SGML characters in String using PHP?</a>).</p> <pre><code>/* * mappings of Windows-1252 (cp1252) 128 (0x80) - 159 (0x9F) characters: * @link http://en.wikipedia.org/wiki/Windows-1252 * @link http://www.w3.org/TR/html4/sgml/entities.html */ $cp1252HTML401Entities = array( "\x80" =&gt; '&amp;euro;', # 128 -&gt; euro sign, U+20AC NEW "\x82" =&gt; '&amp;sbquo;', # 130 -&gt; single low-9 quotation mark, U+201A NEW "\x83" =&gt; '&amp;fnof;', # 131 -&gt; latin small f with hook = function = florin, U+0192 ISOtech "\x84" =&gt; '&amp;bdquo;', # 132 -&gt; double low-9 quotation mark, U+201E NEW "\x85" =&gt; '&amp;hellip;', # 133 -&gt; horizontal ellipsis = three dot leader, U+2026 ISOpub "\x86" =&gt; '&amp;dagger;', # 134 -&gt; dagger, U+2020 ISOpub "\x87" =&gt; '&amp;Dagger;', # 135 -&gt; double dagger, U+2021 ISOpub "\x88" =&gt; '&amp;circ;', # 136 -&gt; modifier letter circumflex accent, U+02C6 ISOpub "\x89" =&gt; '&amp;permil;', # 137 -&gt; per mille sign, U+2030 ISOtech "\x8A" =&gt; '&amp;Scaron;', # 138 -&gt; latin capital letter S with caron, U+0160 ISOlat2 "\x8B" =&gt; '&amp;lsaquo;', # 139 -&gt; single left-pointing angle quotation mark, U+2039 ISO proposed "\x8C" =&gt; '&amp;OElig;', # 140 -&gt; latin capital ligature OE, U+0152 ISOlat2 "\x8E" =&gt; '&amp;#381;', # 142 -&gt; U+017D "\x91" =&gt; '&amp;lsquo;', # 145 -&gt; left single quotation mark, U+2018 ISOnum "\x92" =&gt; '&amp;rsquo;', # 146 -&gt; right single quotation mark, U+2019 ISOnum "\x93" =&gt; '&amp;ldquo;', # 147 -&gt; left double quotation mark, U+201C ISOnum "\x94" =&gt; '&amp;rdquo;', # 148 -&gt; right double quotation mark, U+201D ISOnum "\x95" =&gt; '&amp;bull;', # 149 -&gt; bullet = black small circle, U+2022 ISOpub "\x96" =&gt; '&amp;ndash;', # 150 -&gt; en dash, U+2013 ISOpub "\x97" =&gt; '&amp;mdash;', # 151 -&gt; em dash, U+2014 ISOpub "\x98" =&gt; '&amp;tilde;', # 152 -&gt; small tilde, U+02DC ISOdia "\x99" =&gt; '&amp;trade;', # 153 -&gt; trade mark sign, U+2122 ISOnum "\x9A" =&gt; '&amp;scaron;', # 154 -&gt; latin small letter s with caron, U+0161 ISOlat2 "\x9B" =&gt; '&amp;rsaquo;', # 155 -&gt; single right-pointing angle quotation mark, U+203A ISO proposed "\x9C" =&gt; '&amp;oelig;', # 156 -&gt; latin small ligature oe, U+0153 ISOlat2 "\x9E" =&gt; '&amp;#382;', # 158 -&gt; U+017E "\x9F" =&gt; '&amp;Yuml;', # 159 -&gt; latin capital letter Y with diaeresis, U+0178 ISOlat2 ); $outputWithEntities = strtr($output, $cp1252HTML401Entities); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload