• Home
  • Random
  • Recent changes
  • Special pages
  • Settings
  • About MOASSpedia
  • Disclaimers
MOASSpedia
  • 216.73.216.147
  • Talk
  • Watchlist
  • Contributions
  • Log in

Template:Numcr2namecr

Template Discussion
  • Language
  • Watch
  • History
  • Edit
    • Page information
    • Permanent link
    • What links here
Template documentation[view] [edit] [history] [purge]

Contents

  • 1 Usage
  • 2 Parameters
  • 3 Technical notes
  • 4 See also

Usage

This template converses a numerical character reference into a named character reference. It converts a number to the named character reference for HTML, also often called a "character entity". The input number can be decimal or hexadecimal.

  • {{Numcr2namecr|A0}} -->  ,  
  • {{Numcr2namecr|160|base=dec}} -->  ,  

By default the numeric base is presumed to be hexadecimal. When the base is decimal, it needs to be specified using "base=dec"

When the number has no related named character, an blank is presented. This message can be overruled:

  • {{Numcr2namecr|61}} -->
  • {{Numcr2namecr|61|notfoundmsg=Not named}} --> Not named

Parameters

  • First parameter, 1= Unnamed, required. Numerical value in hex or decimal. Hexadecimal can have the prefix "0x". Input like   (expected output  ) can not be processed.
  • base= Required when base=decimal, default base=hex. When the input number (parameter 1) is decimal, the base= must be defined through: "base=dec", "base=d", "base=10".
For clarity in code, the hex base may be defined as well: "base=hex", "base=h", "base=16". The base is also hexadecimal when the prefix "0x" is used with the number.
  • notfoundmsg= Optional message, default= (blank). Will be returned when the value does not have a named reference.
  • {{numcr2namecr|61}} -->
  • {{numcr2namecr|61|notfoundmsg=Cannot find the name}} --> Cannot find the name

Technical notes

The template uses the module Module:Numcr2namecr, which contains a list of all 2032 character names (or 1446 unique characters). Hexadecimal-decimal calculations are performed by {{#invoke:BaseConvert|16to10}}.

See also

  • List of XML and HTML character entity references gives background and an overview
The above documentation is transcluded from Template:Numcr2namecr/doc. (edit | history)
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this template.
Retrieved from "https://moasspedia.org/w/index.php?title=Template:Numcr2namecr&oldid=25578"
Category:
  • Conversion templates
Last edited on 27 April 2021, at 15:17

MOASSpedia

Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • This page was last edited on 27 April 2021, at 15:17.
  • Content is available under Creative Commons Attribution-ShareAlike unless otherwise noted.
  • Privacy policy
  • About MOASSpedia
  • Disclaimers
  • Desktop