__EXPECTED_UNCONNECTED_PAGE__

This template produces a formatted description of the Unicode character for a given codepoint, to be used inline or otherwise with regular text.

  • The character {{unichar|a9}} is about intellectual property. →
    The character U+00A9 © <reserved-00A9> is about intellectual property.

(To provide the equivalent output for a given character, use {{unichar2}}: this will also return its codepoint value.)

Usage

The {{unichar}} template takes the Unicode hexadecimal code point value as input. Thus, for example, {{unichar|00A9}} → U+00A9 © <reserved-00A9>.

This template produces a formatted description of the Unicode code point for a character, to be used in-line with regular text. It follows the standard Unicode presentation of a character, using the "U+" prefix for displaying the hex code point, followed by a representative glyph, then optionally by the character name, using Unicode's small caps formatting recommendation.

The hexadecimal value is required (e.g. 00A9), other input is optional. Provided that the reader's system has a default font that contains the character, a representative glyph is rendered using it. (If not, then the system font's .notdef symbol will be used. To show a relevant glyph, the font character can be overridden with an image.). If a more specific glyph is preferred, e.g. to language- or IPA-specific fonts, this can be specified. A wikilink can be created to an article about the character, or about the set of characters of that type, and optionally another to the article about Unicode itself. It is also possible to add a custom note.

Some special code points are given extra care, like control and space characters. These are handled automatically (by the unichar/gc sub-template) without user intervention.

Examples

  • {{unichar|00A9}}
    U+00A9 © <reserved-00A9>
  • {{unichar|00A9|nlink=}}
    U+00A9 © <reserved-00A9>
  • {{unichar|00A9|nlink=|note={{crossref|See also [[Copyleft]] symbol}}}}
    U+00A9 © <reserved-00A9> (See also Copyleft symbol)
  • {{unichar|00A9|nlink=|html=}}
    U+00A9 © <reserved-00A9> (&copy;, &COPY;)
  • {{unichar|030D|cwith=◌}} or {{unichar|030D|cwith=&#x25CC;}}
    U+030D ◌̍ <reserved-030D>
  • {{unichar|4E95|note={{zh|p=jǐng|labels=no}}}}
    U+4E95 井 CJK UNIFIED IDEOGRAPH-4E95 (jǐng)
  • {{unichar|0}}
    U+0000 <control-0000>
    • control characters are handled specially
  • {{unichar|0|ulink=C0 control characters|note=[[Null character|NULL]]}}
    U+0000 <control-0000> (NULL)
    • control characters don't have a canonical name

Parameters

The blank template, with all parameters, is as follows:

{{unichar
| ulink  =
| image  =
| cwith  =
| suffix =
| size   =
| use    =
| use2   =
| nlink  =
| html   =
| note   =
| name   =
| alias  =
}}

Inline version:

{{unichar| <!--hex value-->|ulink= |image= |cwith= |suffix= |size= |use= |use2= |nlink= |html= |note= }}
  • First unnamed parameter or |1= (Required) The hexadecimal value of the code point, e.g. 00A9. Prefixing with 0x or U+ is allowed.
    Notes: The parameter accepts input like A9, a9 and 00A9 as hexadecimal value. Warning Decimal values are not detected as being decimal, and will give unexpected results (see also § Possible errors, below).
  • Second unnamed parameter (The Unicode Consortium's canonical name is fetched from Wikimedia Commons, there is no longer any need to specify it manually. If supplied, it is ignored. )
  • |nlink=name Optional hyperlink to the target article. Name of the Wikipedia page that will be linked to. If used, the Unicode name has a wikilink to the article.
    {{unichar|00A9|nlink=}} → U+00A9 © <reserved-00A9>
    {{unichar|00A9|nlink=Copyright symbol}} → U+00A9 © <reserved-00A9>
    Notes:
    • The form nlink= (without any detail) is the most common way to use this option, to link to the article about the symbol using its canonical name.
    • When used without a name (i.e., |nlink=, blank with no value), the link points to the article about the character itself except when that causes a problem with technical restrictions on naming, in which case the name of the character is used or an error is produced if no such name exists (see § Presentation effects).
    • The name of the page is case-sensitive as with all Wikipedia pages.
    • It is possible to give a Wiktionary page here, using the syntax nlink=wikt:<target article>, which may be appropriate if there is no suitable Wikipedia article. For example:
    • Use of this parameter to link to any article other than the one at the canonical name (even if that is a redirect) is potentially an intuitive linking violation, so such use is exceptional and must have a clear justification. ['Copyright sign' and 'copyright symbol' are used here for illustration only and nlink would not normally be used in this case.]
  • |cwith= Optional. The only valid content is ◌ or (or its HTML code, &#x25CC;). It may also be used without any content (i.e., |cwith=, blank with no value). This parameter is useful when the Unicode character is combining (such as a combining diacritic). Using |cwith=◌, the character will be combined with the placeholder symbol, U+25CC ◌ <reserved-25CC>.
    without a |cwith=:
    {{unichar|0485}} → U+0485 ҅ <reserved-0485>
    |cwith= with dotted circle:
    {{unichar|0485|cwith=◌}} → U+0485 ◌҅ <reserved-0485> or
    {{unichar|0485|cwith=&#x25CC;}} → U+0485 ◌҅ <reserved-0485>
    |cwith= without an argument:
    {{unichar|0485|cwith=}} → U+0485 ◌҅ <reserved-0485>
    • Note that cwith=◌◌ alone does not provide the desired result if the intention is to display a diacritic that spans two characters (such as those in the range U+035C to U+0362): the diacritic will be offset. In such cases, editors must use cwith=◌ together with suffix=◌ to place two dotted circles – one on either side of the codepoint for the combining diacritic.
      {{unichar|035F|cwith=◌|suffix=◌}} → U+035F ◌͟◌ <reserved-035F>
    • Use of any other character except dotted circle as input to |cwith= is deprecated; this restriction is not currently enforced but if any other character is used, the output (grapheme and description) is at best misleading.
    • For scripts other than Latin, use of the parameters use=lang and use2= may additionally be needed for better rendering.
  • |suffix= Optional. Its contents directly follow the character. The only supported uses of this parameter are for diacritics that span two characters (see |cwith= above) and for appending variation selectors to certain characters.
    For example, using U+FE0E ︎ VARIATION SELECTOR-15 which forces emoji to display as text, one can have:
    {{unichar|01F604|suffix=&#xFE0E;|note=with {{unichar|FE0E}}}} → U+1F604 😄︎ <reserved-1F604> (with U+FE0E ︎ VARIATION SELECTOR-15)
    Since variation selectors change the appearance of the character, their presence should always be mentioned in a |note= or in prose.
    The Unicode Consortium has decided that it was a mistake to unify traditional and emoji forms, so the 'variation selector' method should be regarded as at best time-limited. It is already not fully functional on some plaforms such as Google Android, always preferring the emoji form. See Variation Selectors (Unicode block).
  • |html= Optional. If a named character reference exists, like "&nbsp;", it is displayed after the character name. Otherwise nothing happens. In particular, numeric character references like &#160; are never displayed. Only the existence of an |html= parameter is checked, everything after the equal sign is ignored so you can leave it blank.
    • {{unichar|160|html=}} → U+0160 Š <reserved-0160> (&Scaron;)
  • |note= Optional. Adds a comment such as a clarification or explanatory note. For example, as the canonical names of ideographs are not generally helpful, the note= option permits an added comment such as U+4E95 井 CJK UNIFIED IDEOGRAPH-4E95 (jǐng)
  • |ulink= Optional. Creates a wikilink from the U+ prefix. When used without a name (i.e., |ulink=, blank with no value), the article Unicode is used as the default value in the output: [[Unicode|U+]] producing U+. This only needs to change if you have a reason to link elsewhere than Unicode, e.g. to an article on a subset of Unicode characters.
  • |use= Optional. Sets the font-hinting template to get the glyph, since the character may not be present in a regular browser font. By default no template is used; the available options are {{IPA}}, {{lang}} and {{script}}.
  • |use2= Optional. When setting |use=lang or |use=script, |use2= should be used to set the language (e.g. |use2=fr) or the script (e.g. |use2=Cyrs). A glyph may still not show as expected due to browser effects. For a detailed description, see each template's documentation.
    {{unichar|0485|cwith=◌|use=script|use2=Cyrs}} → U+0485 ◌҅ <reserved-0485>
    {{unichar|3099|cwith=◌|use=lang|use2=ja}} → U+3099 ◌゙ <reserved-3099> (If use+use2 are not used, the Japanese diacritic dakuten is not shown properly by some browsers.)
  • |image= Optional. Allows for a graphic image file to represent the glyph; overrides the font completely. The filename should include the extension (like .svg or .png), but not the prefix File:.
    • Depending on the image used, class=skin-invert might be needed so the image displays correctly in dark mode. Compare:
      {{unichar|20B9|image=Indian Rupee symbol.svg{{!}}class=skin-invert}} → U+20B9 <reserved-20B9> <reserved-20B9>
      {{unichar|20B9|image=Indian Rupee symbol.svg}} → U+20B9 <reserved-20B9> <reserved-20B9>
    • This option is rarely needed: it is intended for use with characters that have been given a codepoint but have yet to be included in mainstream system fonts. It is good practice to add a (hidden) comment to explain why its use has been needed, as in time that will cease to be the case. It is no longer appropriate to use it with the Indian Rupee sign, for example.
  • |size= Optional. Can be used to set the size of the glyph. The default value is 125%. For the font, all CSS font-size style inputs are accepted: 7px, 150%, 2em, larger.
    • For example, {{unichar|0041|size=2em}} → U+0041 A <reserved-0041>
    • When using an image (file) instead of a font, this size can only accept sizes in px like 12px. Default for images is 10px.
  • |name=. Optional; if used, the only permitted content is none. This parameter is provided for the rare cases where only the code-point and the corresponding character are wanted.
    • For example, {{unichar|a9|name=none}} produces U+00A9 © .
  • |alias=. Optional; if used, the only permitted content is yes. The purpose of this parameter is to handle the very rare cases where the Unicode Consortium has identified that a name is seriously defective and misleading, or has a serious typographical error, and has defined a formal alias that applications are encouraged to use in place of the official character name. (See Unicode#Alias for details.)
    • For example, U+A015 YI SYLLABLE WU has the formal alias YI SYLLABLE ITERATION MARK. Thus, rather than {{unichar|A015}} → U+A015 ꀕ <reserved-A015>, the style {{unichar|A015|alias=yes}} → U+A015 ꀕ YI SYLLABLE ITERATION MARK is preferred in most contexts.

Presentation effects

Since this template is aimed at presenting a formatted, inline description, some effects are introduced to sustain this target.

  • Showing space characters: All space characters (those with General Category: Zs) are presented with a light-blue background, to show their actual presence and width: U+00A0   <reserved-00A0>.
    Incidentally, the regular space   is replaced with &#00A0; (NBSP) to prevent wiki-markup deleting it as repeated spaces.
  • Removing formatting characters: Formatting characters (those with General Category: Cf, Zl and Zp) are removed from the output. By definition, formatting characters have no glyph. By removing them they cannot have a formatting effect.
    Exception: five Arabic Cf/formatting number markings U+0600..U+0603 and U+60DD, are shown. While Cf formatting characters usually have no glyph, these five have. By internally adding "(visible)" to the category, these characters are shown.
  • Removing whitespace: The template removes formatting code and surrounding whitespace from the input. A <Return> in the Name-input (possibly unintended) would frustrate the in-line behaviour expectation.
  • Showing a label like <control-0007>: Unicode states that a code point has no name when it is one of these: a control character, a private use character, a surrogate, a not assigned code point (reserved), or a non-character. These code points instead should be referred to by using a "Code Point Label", such as <private-use> or <private-use-E000>. In this situation, this template replaces the glyph with that label. This way, the correct presentation wins it over Unicode-usage to the letter of the law.
    • "Control" general category=Cc: <control> or <control-0007>
    • "Surrogate" general category=Cs: <surrogate> or <surrogate-D800>
    • "Private Use": general category=Co: <private-use> or <private-use-E000>
    • "Not a character" (minus the reserved code points, see below): general category=Cn: <not-a-character>, <non-character> or <not-a-character-FFFE>
    The second parameter (Unicode name) is not presented, since it cannot exist. It is possible to create a link to an article.
    Note: A <reserved> (unassigned) code point cannot be detected yet, and so is not presented with this label. These code points too are given Cn category.
    (Background on <>-labels: A Name can never have <>-brackets at all. These rules prevent mixing up a name with an actual control-character. So it will not happen that a bell rings when a page is opened that contains a Name of U+0007).

Possible errors

  • The template produces an Error-message when |1= (or first unnamed parameter), the hex value, is missing, empty, or invalid.
  • A non-hexadecimal input like 00G9 produces an error (because G or g is not hexadecimal).
  • The glyph may be overruled and changed into a label like <control-0007>. These characters have no Unicode name. An nlink will be directly to the article (entered in a form like |nlink=Bell signal). A blank value of just |nlink= cannot work for <label-hhhh> characters (there is no character name at all to make into a link). This produces an error.
  • A decimal-value input like |1=98 will be read as being hexadecimal value 0098. There is no way that the template can detect you intended to enter 9810=6216. No warning is issued, and the wrong character, U+009816, will be shown (not U+0062).
  • The alias= cannot be used to create an unofficial alias.
  • If alias=yes is used but the code point does not have an official alias, no name whatever will be displayed.
  • The text provided in nlink= should be the normal name of an article. Do not type it in all caps as a red link will result.

Tracking

Technical notes

The string "unichar" is used only in English Wikipedia, as a name for this template. It has no meaning outside this context.

The template uses these subtemplates:

  • {{unichar/main}} Accepts all the input from {{unichar}}. Calls several subtemplates to produce the textstrings, and then strings them together. Also checks for the error non-hex input.
  • {{unichar/ulink}} Creates a piped link for the U+ prefix.
  • {{unichar/gc}} Determines the Unicode general category, when this category is special (like, for control characters).
  • {{unichar/glyph}} For rendering the glyph by font. Accepts |image=, which overrides the font. Also processes |use=, |use2=, |size=, |cwith=.
  • {{unichar/name}} Produces the formatted name of the character in smallcaps. Accepts the |nlink= to create a piped wikilink to an article. When the general category (gc) is special, the name will change into a <label-hhhh>.
  • {{unichar/notes}} Shows notes in parentheses (round brackets): HTML (from |html= named entity like &nbsp; if that exists, using {{#invoke:LoadData|Numcr2namecr}}); and the free-text |note=.
  • Using the main template as an easy-input feature, there are few calculations done (actually only two hex2dec), and allows for adding default values not too deep in the templates.
  • The value <#salted#> is used internally to pass through a non-defined input parameter. This value is correct when about the Unicode name, because it cannot have the characters <##>, and so salted is the right word (meaning uninhabitable). For ease of code maintenance, it is used in various places in the code.
  • Named entities for U+22C1 ⋁ <reserved-22C1>: {{#invoke:LoadData|Numcr2namecr|0x22C1}} → &bigvee;, &Vee;, &xvee;

Issues

  • Unassigned code points, to be labelled <reserved>, cannot be detected.
  • When using |use-script=, then |use2= needs lowercase (e.g. 0485, Cyrs or cyrs)[clarification needed]
  • When using for one of the RTL formatting marks, its effect may break out of the template (text following the template goes RTL, too). As it is now, this requires extra code.

Code charts

Key to the Unicode Code Charts (Ch 24)[1]
Symbol Meaning Examples
※ Character name alias ※ LATIN SMALL LETTER GHA
= Informative alias(es) = barred o, o bar
• Informative note
  • • lowercase is 0275 ɵ
  • • Portuguese, Estonian
  • • this is a spacing character
→ Cross-reference → 0283 ʃ latin small letter esh
≡ Canonical decomposition mapping ≡ 0075 u 031B ◌̛
≈ Compatibility decomposition mapping ≈ 006E n 006A j
~ Standardized variation sequence ~ 2205 FE00 zero with long diagonal stroke overlay form

TemplateData

This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Unichar in articles based on its TemplateData.

TemplateData for Unichar

See also

U+00A9 → 169dec → &copy; (as literal code, not the character)

Useful links for researching Unicode characters:

  • Unicode.org charts in PDF format, showing the U+ hex values.
  • Unicode Consortium 's character properties overview, e.g comma U+002C: [2]


Template:Unichar invokes Module:Navbox using Lua.

Usage

This template can be used to make a standard navigation box. It is intended for use within another template that standardises the title and contents of the box (see Template:ShipNavbox). This template SHOULD NOT be used directly within articles, as it creates a maintenance burden to do so whenever the contents of the box have to be updated.

The purpose of this template is to standardise the attributes of all navigation boxes, for example, their colours and other CSS attributes. The template is fairly simple, and could be extended to add other features in the future. Using this template allows changes to be implemented much quicker and easier than editing each template separately.

Syntax

{{navbox
|state      = uncollapsed, collapsed, plain, autocollapse (default)
|name       = mandatory - name of the template
|style      = optional - style for the whole table
|title      = mandatory - navbox header
|gtitleN    = optional - title of N-th group of items
|styleN     = optional - style for groupN; i.e. text-align
|groupN     = mandatory - list of groups of items
|fstyle     = optional - style for footer ; i.e. text-align
|footer     = optional - navbox footer
}}
  • Groups: Currently there is no technical limit to the maximum number of groups.
    • Groups of items can be added as parameters: group1, group2, group3, ... up to groupN.
  • Group title: Each group has its own title parameter: gtitle1, gtitle2, gtitle3, ... up to gtitleN. Note that the default width for the first column is 15%.
  • Group style: Style may also be customised to each group in: style1, style2, style3, ... up to styleN.
    • Note that neither the title nor the items have any wiki-links built into the template. As a result, users of the template are free to use wiki-links as they wish.
  • Line breaks: Line-breaks (<br />) are unnecessary, as text wrapping is done automatically by the template. This also includes links and text in gtitleN and groupN.
  • Bullets: Create unordered lists with lines beginning with *.
  • Pipe links: Because of the nature of template syntax, it may be necessary to use Template:! ({{!}}).

States

  • Autocollapse: By default, the state of a navbox is "autocollapsed". This means that if the number of navboxes in a page exceeds the maximum allocation of the collapsible navboxes, then the remaining navboxes are collapsed automatically. For more information (or to change the setting), see MediaWiki:Common.js.
    • Currently, the autocollapse allocation is 2 (see MediaWiki:Common.js). This means that if there are 3 navboxes in a page, the third and subsequent navboxes will be collapsed automatically.
  • Uncollapsed: Forces the navbox to be displayed.
    • All of the navboxes in this documentation are in the uncollapsed state.
  • Collapsed: The reverse of uncollapsed. Forces the navbox to be hidden instead.
    • Navboxes with a height of more than 300 pixels will also be collapsed automatically. For more information (or to change the setting), see MediaWiki:Common.js.
  • Plain: Removes the "show/hide" link.

Sub-groups

  • For larger navboxes, it may be necessary to include sub-groups within a particular group of items. It is also possible to collapsible navboxes within the parent navbox, see Collapsible sub-groups.
  • To create sub-groups within {{navbox}}, certain parameters are to be included:
    • The parent navbox group (i.e. group2 in the example below) requires the type parameter (gtype2 = Subgroup).
    • The nested navbox (sub-group) requires the inclusion of the sub-group parameter (subgroup = yes). This enables the template to differentiate between the sub-group and the parent navbox.
{{navbox
|name    =
|title   =
|gtitle1 =
|group1  =
|gtitle2 =  
|gtype2  = Subgroup (mandatory)
|group2  = 
  {{navbox
  |subgroup = yes (mandatory)
  |gtitle1  = 
  |group1   =
  |gtitle2  = 
  |group2   = 
  }}
}}

Collapsible sub-groups

  • For extremely long navboxes, it is recommended to use collapsible navboxes within the parent navbox. Further sub-groups can then be added to these collapsible navboxes.
  • To create collapsible sub-groups within {{navbox}}, these parameters need to be included:
    • The parent navbox is almost always uncollapsed (state=uncollapsed).
    • The parent navbox group (i.e. group1 in the example below) requires the type parameter (gtype1 = Subgroup).
    • The nested collapsible navbox requires the inclusion of the collapsible parameter (collapsible = yes). This enables the template to differentiate between the collapsible navbox and the parent navbox.
    • The nested collapsible navbox is forcefully collapsed (state=collapsed).
{{navbox
|state  = uncollapsed
|name   = 
|gtype1 = Subgroup
|group1 = 
  {{navbox
  |collapsible = yes
  |state   = collapsed
  |title   = 
  |gtitle1 = 
  |group1  = 
  |gtitle2 = 
  |group2  = 
  }}
}}

Use of images

  • The use of images in navboxes is permitted, but please resize the images to keep them small. Inventory-sized images (25-30 pixels) are recommended.
  • Please use {{t|plink}} to create links with images. Use {{t|plink}} for any case where text is not desired after the link. It functions the same as {{t|plink}}, but it does not produce a wikilink in text. Use {{t|chatl}} to link chatheads. These templates create links for both the image and text (except for {{t|plink}}) using far less wikicode than the standard syntax.

Link and file share the same name

{{plink|Item}}

File name differs from the link

{{plink|Item|File}}

Link and file share the same name, but different text is desired to display

{{plink|Item|alt=Text}}

File name differs from the link and different text is desired to display

{{plink|Item|File|alt=Text}}

Categorising

Navboxes are very useful for transcluding categories onto a large number of pages that share both a trait and the navigation box. For example: Template:ShipNavbox transcludes Category:Ships onto every page that uses it.

There are 2 methods of categorising pages with navboxes:

The first way is with {{t|Ctg}}. This is the preferred method, and can be used in most cases. The rules and operations for the Category handler template are very simple; however, they are enough to produce the desired results on most pages.

Categorisation should only be used on a template for large-scale addition. It is unhelpful, for example, to use a rule that only applies to 1 page.

Examples

To see the following navboxes in action, see Template:Navbox.

Single line navbox with centered list

{{navbox
|name    = 
|title   = 
|style1  = text-align:center
|group1  =
}}
{{navbox
|name    = 
|title   = 
|gtitle1 = 
|group1  = 
|footer  = Centered footer
}}
{{navbox
|name    = 
|title   = 
|gtitle1 = 
|group1  = 
|fstyle  = text-align:right
|footer  = Right-aligned footer
}}

Multiple line navbox

{{navbox
|name    = 
|title   = 
|gtitle1 = Group title 1
|group1  = 
|gtitle2 = Group title 2
|group2  = 
|gtitle3 = Group title 3
|group3  = 
}}

Collapsed navbox

{{navbox
|state   = collapsed
|name    = 
|title   = 
|style1  = text-align:center
|group1  = 
}}

Plain navbox with Tnavbar

{{navbox
|state   = plain
|name    = 
|title   = 
|style1  = text-align:center
|group1  = 
}}

Plain navbox without Tnavbar

{{navbox
|state   = plain
|title   = 
|style1  = text-align:center
|group1  = 
}}

Complicated navbox

{{navbox
|state   = uncollapsed
|name    = 
|title   = 
|gtitle1 = Level 1 Title 1
|group1  = 
|gtitle2 = Level 1 Title 2
|group2  = 
|gtitle3 = Level 1 Title 3
|group3  = 
|gtitle4 = Level 1 Title 4
|group4  = 
|gtitle5 = Level 1 Title 5
|gtype5  = Subgroup
|group5  = 
  {{navbox
  |subgroup = Yes
  |gtitle1  = Level 2 Title 1
  |group1   =
  |gtitle2  = Level 2 Title 2
  |group2   =
  |gtitle3  = Level 2 Title 3
  |gtype3   = Subgroup
  |group3   = 
    {{navbox
    |subgroup = Yes
    |gtitle1  = Level 3 Title 1
    |group1   =
    |gtitle2  = Level 3 Title 2
    |group2   =
    }}
  |gtitle4  = Level 2 Title 4
  |group4   = 
  }}
|gtitle6 = Level 1 Title 6
|group6  = 
|gtitle7 = Level 1 Title 7
|group7  = 
|fstyle  = 
|footer  = 
}}

Preventing unwanted documentation

The Navbox template's documentation is automatically transcluded under the navbox on any Template namespace page. It is not transcluded when used as a sub-group or collapsible sub-group template (subgroup= yes or collapsible=yes).

Should the documentation appear when it is unwanted, it can be hidden by setting the doc parameter doc=no on the template. In most cases, the doc parameter is NOT used and the parameter is removed completely.