Template:Numcr2namecr/doc

From English Wikipedia @ Freddythechick

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.

  • <syntaxhighlight lang="wikitext">&nbsp;, &NonBreakingSpace;</syntaxhighlight> produces: &nbsp;, &NonBreakingSpace;
  • <syntaxhighlight lang="wikitext">&nbsp;, &NonBreakingSpace;</syntaxhighlight> produces: &nbsp;, &NonBreakingSpace;

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:

  • <syntaxhighlight lang="wikitext"></syntaxhighlight> produces:
  • <syntaxhighlight lang="wikitext">Not named</syntaxhighlight> produces: Not named

Parameters

  • First parameter, unnamed, |1= : Required. Numerical value in hex or decimal. Hexadecimal can have the prefix "0x". Input like &#160; (expected output &nbsp;) 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.
  • <syntaxhighlight lang="wikitext"></syntaxhighlight> produces:
  • <syntaxhighlight lang="wikitext">Cannot find the name</syntaxhighlight> produces: 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


pt:Predefinição:Numcr2namecr/doc