Editing
Module:DecodeEncode/doc
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Decode ({{mono|1=&copy;}} → ©) <span class="anchor" id="Decode"></span>== {{hatnote|See {{slink||Known issues}} for possible THIN SPACE, epsilon issues}} :Decodes [[List of XML and HTML character entity references|Named Entities]] ''from'' entity name ''into'' a regular (unicode) character: :<code>&copy;</code> → <code>©</code> :<code>&gt;</code> → <code>></code> All welldefined named entities are decoded ([https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references HTML Named character references], formally: as defined in the [https://www.php.net/get_html_translation_table PHP table]). :A regular, rendered sentence: ::"At 100 °F, & with a "burning" sun above, we , we ⁄walked⁄." :In code: ::"<code>At 100&nbsp;&deg;F, & with a &quot;burning&quot; sun above, we &frasl;walked&frasl;.</code>" -- wikitext :Processing: :<code><nowiki>{{#invoke:decodeEncode|decode|s=At 100 °F, & with a "burning" sun above, we ⁄walked⁄.}}</nowiki></code> → ::<code>{{#invoke:decodeEncode|decode|s=At 100 °F, & with a "burning" sun above, we ⁄walked⁄.}}</code> -- In code: straight characters, no named entities. :Renders, again: ::"At 100 °F, & with a "burning" sun above, we ⁄walked⁄." ===Decode a reduced set only=== By setting {{para|subset_only|true}}, only these five entity names are decoded: '&lt;', '&gt;', '&amp;', '&quot;', '&nbsp;' (that is, into '<', '>', '&', '"', ' '). :'''Note''': There is a difference with the relevant Lua parameter. (This only concerns your task if you also work directly with the Lua mw.text.decode function). Lua documentation defines parameter {{para|decodeNamedEntities}}, having this effect: when ''omitted or false'', only the reduced set of entities is recognized and decoded. This use of 'false' is ''inverted'' in using {{para|subset_only}}: {{para|decodeNamedEntities|false}} = {{para|subset_only|true}}. :Also, this module ignores the "omitted" logic: {{para|subset_only}} should be set explicitly to 'true' to be effective.
Summary:
Please note that all contributions to IDU Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
IDU Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
To edit this page, please answer the question that appears below (
more info
):
Who is the wiki admin
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Module
Discussion
English
Views
Read
Edit source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information