https://wiktenauer.com/index.php?title=Template:Unichar/doc&feed=atom&action=historyTemplate:Unichar/doc - Revision history2024-03-28T17:01:37ZRevision history for this page on the wikiMediaWiki 1.34.2https://wiktenauer.com/index.php?title=Template:Unichar/doc&diff=17693&oldid=prevMichael Chidester: 1 revision2012-09-23T03:03:56Z<p>1 revision</p>
<p><b>New page</b></p><div>{{Documentation subpage}}<br />
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS AT THE BOTTOM OF THIS PAGE --><br />
This template produces a formatted description of a [[Unicode]] character, to be used in-line with regular text. <br />
* I like {{tlx|unichar|<nowiki>a9|Copyright sign</nowiki>}}. &rarr; I like {{unichar|a9|Copyright sign}}.<br />
<br />
==Usage==<br />
This template produces a ''formatted description'' of a [[Unicode]] character, to be used ''in-line'' with regular text. It needs Unicode hexadecimal value and name as input, like <code><nowiki>{{unichar|00A9|Copyright sign}}</nowiki></code> &rarr; {{unichar|00A9|Copyright sign}}.<br />
<br />
It follows the standard Unicode presentation of a character such as using the pattern "U+00A9", and allowing Unicode's all caps naming habit (which is undesired in Wikipedia text) by using {{smallcaps|small caps}}. The hexadecimal value is required (e.g. A9), other input is optional. The actual glyph is looked for in a font that covers Unicode quite well, and this can be set more specific to e.g. language or IPA-specialized fonts. To show the glyph, the font character can be overridden with an image. A wikilink to an article and another to Unicode can be created, it is possible to add (in brackets), the calculated decimal value, HTML-notations, and a note.<br />
<br />
Some special code points are given extra care, like controls and space characters. These special code points are automatically detected by the [[Template:unichar/gc|unichar/gc]] sub-template.<br />
<br />
===Examples===<br />
* <code><nowiki>{{unichar|00A9|Copyright sign}}</nowiki></code> &rarr; {{unichar|00A9|Copyright sign}}<br />
* <code><nowiki>{{unichar|00A9|Copyright sign|nlink=Copyright symbol}}</nowiki></code> &rarr; {{unichar|00A9|Copyright sign|nlink=Copyright symbol}}<br />
* <code><nowiki>{{unichar|00A9|Copyright sign|nlink=Copyright symbol|note=See also [[Copyleft]] symbol}}</nowiki></code> &rarr; {{unichar|00A9|Copyright sign|nlink=Copyright symbol|note=See also [[Copyleft]] symbol}}<br />
* <code><nowiki>{{unichar|00A9|Copyright sign|nlink=Copyright symbol|dec=|html=}}</nowiki></code> &rarr; {{unichar|00A9|Copyright sign|nlink=Copyright symbol|dec=|html=}}<br />
* <code><nowiki>{{unichar|00A0|No-break space|note=NBSP}}</nowiki></code> &rarr; {{unichar|00A0|No-break space|note=NBSP}}<br />
* <code><nowiki>{{unichar|0007|nlink=Bell character}}</nowiki></code> &rarr; {{unichar|0007|nlink=Bell character}}<br />
<br />
===Parameters===<br />
The blank infobox, with all parameters, is as follows:<br />
<pre><br />
{{unichar<br />
| <!-- hex value, code point (do not add the "U+") --><br />
| <!-- Unicode name --><br />
| ulink =<br />
| image =<br />
| cwith =<br />
| size =<br />
| use =<br />
| use2 =<br />
| nlink =<br />
| dec =<br />
| html =<br />
| note =<br />
}}<br />
</pre><br />
<br />
* '''First parameter''', '''1=''' Unnamed, required (prefix "1=" may be omitted). The hexadecimal value of the code point, e.g. {{code|00A9}}.<br />
:''Notes'': The parameter accepts input like {{code|A9}}, {{code|a9}} and {{code|00A9}} as hexadecimal value. Decimal values are not detected being decimal, and will give unexpected results (see Error messages, below).<br />
<br />
* '''Second parameter''', '''2=''' Unnamed (prefix "2=" may be omitted). The Unicode name of the character. The template uses this input as the {{Smallcaps|name in small caps}}, forced into these small capitals whatever the input. This name may differ from the name of the corresponding Wikipedia article (see below: nlink=).<br />
<br />
* '''nlink=''' Optional.wikilink. Name of the Wikipedia page that will be linked to. If used, the Unicode name (second parameter) has a wikilink to the article. When the article name and the Unicode name are the same, using a straight "nlink=" without a name will do. <br/><br />
::For control characters using the ''nlink'' parameter, the Unicode name parameter is not used: the ''nlink'' parameter is displayed instead, without small caps.<br />
:''Note'': the name of the page is case sensitive as with all wikipages.<br />
<br />
:<code><nowiki>{{unichar|00A9|Copyright sign|nlink=Copyright symbol}}</nowiki></code> &rarr; {{unichar|00A9|Copyright sign|nlink=Copyright symbol}}<br />
:<code><nowiki>{{unichar|00A3|Pound sign|nlink=}}</nowiki></code> &rarr; {{unichar|00A3|Pound sign|nlink=}}.<br />
<br />
* '''ulink''' Optional. Creates a wikilink in the "U+" prefix. When used without name ({{code|ulink={{!}}}}), the default value, [[Unicode]] page, is used: [[Unicode|U+]].<br />
<br />
* '''dec=''' Optional. Adds the decimal value to the text, in hte bracketed note.<br />
* '''html=''' Optional. Adds the HTML character reference to the text, like <code>&amp;#160;</code> in the bracketed note. If a ''named character reference'' exists, like <code>"&amp;nbsp;"</code>, that is added too.<br />
*'''use=''' Optional. Sets the font-hinting template to get the glyph, since the character may not be present in a regular browser font. Default is {{tl|unicode}}, other options are {{tl|IPA}}, {{tl|lang}} and {{tl|script}}. When setting "use=lang" or "use=script", '''use2''' should be used to set the language ("use2=fr") or the script ("use2=Cyrs"). A glyph may still not show as expected due to browser effects. For a detailed description, see the templates documentation.<br />
* '''image=''' Optional. Allows for a ''file'' (graphic image) to represent the glyph, overrules the font completely. The filename should include the extension like ".svg", but ''not'' the prefix "File:".<br />
* '''cwith=''' Optional. Useful when the Unicode character is ''combining''. Using {{code|1=cwith=}} adds a space before the character, allowing the combining effect. So when used with a character like {{code|1=cwith=a}}, the character will be combined with the letter "a". In Unicode, a general glyph used to place a combined is {{unichar|25CC|DOTTED CIRCLE|html=}}.<br />
* <code><nowiki>{{unichar|0485|COMBINING CYRILLIC DASIA PNEUMATA|cwith=}}</nowiki></code> &rarr; {{unichar|0485|COMBINING CYRILLIC DASIA PNEUMATA|cwith=}}<br />
* <code><nowiki>{{unichar|0485|COMBINING CYRILLIC DASIA PNEUMATA|cwith=|use=script|use2=Cyrs}}</nowiki></code> &rarr; {{unichar|0485|COMBINING CYRILLIC DASIA PNEUMATA|cwith=|use=script|use2=Cyrs}}<br />
<br />
* '''size=''' Optional. Can be used to set the size ''of the glyph''. By default "size=125%". For the font, all font-size style inputs are accepted: "7px", "150%", "2em", "larger".<br />
:<code><nowiki>{{unichar|0041|LATIN CAPITAL LETTER A|size=2em}}</nowiki></code> &rarr; {{unichar|0041|LATIN CAPITAL LETTER A|size=2em}}<br />
: When using an ''image'' (file) instead of a font, this size can only accept sizes in px like "12px". Default for images is "10px" .<br />
<br />
<pre><br />
{{unichar<br />
| A9<br />
| Copyright sign<br />
| ulink = Unicode character mapping<br />
| image = <br />
| size = 150%<br />
| nlink = Copyright symbol<br />
| note = Example<br />
}}<br />
</pre> Produces:<br />
* {{unichar<br />
| A9<br />
| Copyright sign<br />
| ulink = Mapping of Unicode characters<br />
| image = <br />
| size = 150%<br />
| nlink = Copyright symbol<br />
| note = Example<br />
}}<br />
<br />
===Presentation effects===<br />
Since this template is aimed at presenting a ''formatted, inline description'', some effects are introduced to sustain this target.<br />
* '''Showing space characters''': All space characters (those with [[Unicode_character_property#General_Category|General Category]]: Zs) are presented with a light-blue background, to show their actual presence and width: <code>{{unichar|00A0|No-break space|nlink=NBSP}}</code>.<br />
:Incidentally, the regular space <nowiki> </nowiki> is replaced with <code>&amp;#00A0;</code> (NBSP) to prevent wiki-markup deleting it as repeated spaces.<br />
<br />
* '''Removing formatting characters''': Formatting characters (those with [[Unicode_character_property#General_Category|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.<br />
<br />
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.<br />
<br />
*'''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.<br />
<br />
* '''Showing a label like <control-0007>''': Unicode states, that an code point has ''[[Unicode character property#General Category|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.<br />
* "Control" general category=Cc: <code><control></code> or <code><control-''0007''></code><br />
* "Surrogate" general category=Cs: <code><surrogate></code> or <code><surrogate-''D800''></code><br />
* "Private Use": general category=Co: <code><private-use></code> or <code><private-use-''FFA0''></code><br />
* "Not a character" (minus the reserved code points, see below): general category=Cn: <code><not-a-character></code>, <code><non-character></code> or <code><not-a-character-''FFA0''></code><br />
<br />
The second parameter (Unicode name) is not presented, since it cannot exist. It is possible to create a link to a article.<br />
:''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.<br />
:(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 character|bell]] rings when a page is opened that contains a Name of U+0007).<br />
<br />
===Possible errors===<br />
* The template produces an {{error|Error-message|tag=span}} when parameter #1 (hex value) is missing.<br />
* A non-hexadecimal input like ''00G9'' produces an error (Because ''G/g'' is not hexadecimal).<br />
* Do not add the U+-prefix like ''U+00A9''. It will not be recognised.<br />
* If the template ''only'' shows the code point number, like "{{unicode|2038}}", you're probably using the wrong template {{tlb|unicode}}, instead of {{tlb|unichar}}.<br />
* 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 "nlink=Bell signal"). A blank like this "nlink=", (which links fine for regular characters like Pound sign), cannot work for <labeled> characters (there is no character name at all to make into a link). This produces an error.<br />
* 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 98<sub>10</sub>=62<sub>16</sub>.No warning is issued, and the wrong character, U+0098<sub>16</sub>, will be shown (''not'' U+0062).<br />
<br />
===Technical notes===<br />
The word "unichar" is used only in this English Wikipedia, as a name for this template. It has no meaning outside.<br><br />
<br />
The template uses these subtemplates:<br />
* {{tl|unichar/main}} Accepts all the input from {{tlx|unichar}}. Calls several subtemplates to produce the textstrings, and then strings them together. Also checks for the error non-hex input.<br />
* {{tl|unichar/ulink}} creates a piped link for the "U+" prefix.<br />
* {{tl|unichar/gc}} determines the Unicode general category, when this category is special (like, for control characters).<br />
* {{tl|unichar/glyph}} for rendering the glyph by font. Accepts "image=" that overrules the font. Uses also "use", "use2", "size", "cwith".<br />
* {{tl|unichar/na}} Produces the formatted name of the character in {{Smallcaps|smallcaps}}. Accepts the "nlink=" to create a piped wikilink to an article. When the [[Unicode_character_property#General_Category|general category]] (gc) is special, the name will change into a <''label''-''hhhh''>.<br />
* {{tl|unichar/notes}} - Produces the three optional notes in brackets: ''decimal value'', ''HTML-character reference'' (both decimal and by name like {{code|&amp;nbsp;}} if that exists using {{tlx|numcr2namecr}}) and the free text ''note'' as provided by the editor. Also does the brackets themselves.<br />
<br />
* Using the main template as an input-easy feature, there are few calculations done (actually only two hex2dec), and allows for adding default values not too deep in the templates.<br />
<br />
* The value "<#salted#>" is used internally to pass through a non-defined input parameter. This value is correct when about the Name, because a Unicode name cannot have the characters <##>, and so [[Salting the earth|salted]] is the right word (meaning uninhibitable). For ease of code maintenance it is used in more places around.<br />
<br />
====Issues====<br />
* Unassigned code points, to be labelled <reserved>, cannot be detected.<br />
* When using use-script, use2 needs lowercase (e.g. 0485, Cyrs or cyrs)<br />
<br />
===See also===<br />
* {{tl|unicode}} - Produces rare characters, using fonts that cover Unicode more widely.<br />
{{Unicode templates}}<br />
<br />
===External links===<br />
Useful links for researching Unicode characters:<br />
* [http://unicode.org/charts/ Unicode charts], gives the chart (in PDF) on which the U+value is located.<br />
* [http://www.fileformat.info/info/unicode/char/search.htm Fileformat.com search], to search by ''name'' (whole or partial), by U+ ''hex value'' or ''decimal value'', by the font ''symbol'' (copy-past it). Extra information per character.<br />
<includeonly><br />
<!-- CATEGORIES AND INTERWIKIS HERE, THANKS --><br />
[[Category:Unicode templates]]<br />
<br />
[[zh:Template:Unichar]]<br />
</includeonly></div>Michael Chidester