Template:Chrfn

From Meta, a Wikimedia project coordination wiki
Template documentation

Character from Number: inverse of Template:Nfchr, decodes a character from an integer in the range 1 - 99.

  • 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
    abcdefghijklmnopqrstuvwxyz
  • 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
    !"#$%&'()*+,-./0123456789:;<=>?
  • 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
    @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
  • 96 97 98 99
    ±×é•
One list: abcdefghijklmnopqrstuvwxyz{|}~!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_±×é• 32-95 is ASCII, 1-30 is ASCII 97-126, 31 is newline, and 96-99 are miscellaneous. 0 produces the empty string, so that digit strings with the same numerical value, e.g. 006502 and 6502, produce the same string (in this case Ab). Thus 99 characters are supported. To avoid an automatic newline, the characters #*:; are returned inside <nowiki> tags. Examples:
  • "{{chrfn|5}}" → "e" [1]
  • "{{chrfn|05}}" → "e" [2]
Special cases:
  • "{{chrfn|0}}" → "" [3]
  • "{{chrfn|}}" → "" [4]
  • "{{chrfn}}" → "" [5]
  • "{{chrfn|32}}" → "" [6]
  • "{{chrfn|31}}" → "" [7]
Example with invalid number:
  • "{{chrfn|a3}}" → "˚" [8]
Example with unsupported value:
  • "{{chrfn|100}}" → "˚" [9]

Supported characters[edit]

The supported characters are a core character set of 95 characters and four other characters ( ± × • é ).

The core character set consists of the basic letters or digits (62), and all characters with a special meaning in MediaWiki (including extensions on Wikimedia wikis), HTML, JavaScript, URLs, and/or email-addresses (33):

space newline {  |  }  ~  !  "  #  $  %  &  '  (  )  *  +  ,  -  .  /  :  ;  <  =  >  ?  @  [  \  ]  ^  _

All magic words in the English version of MediaWiki, and even in many other versions since they are often not translated, use the core character set only. Some language versions allow both English and local magic words, which may or may not contain unsupported characters, see e.g. [10], [11]. Results from formatnum may even contain local digits, which are not in this character set.

Parameter names[edit]

All 99 characters can be used in a parameter name:

{{pp|1=abcdefghijklmnopqrstuvwxyz{ {{!}} }~ 
!"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_±×•é|abcdefghijklmnopqrstuvwxyz{ {{!}} }~ 
!"#$%&'()*+,-./0123456789:;<{{=}}>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_±×•é=q}}

gives q.

Page titles[edit]

Not allowed are: # < > [ ] | { } newline

The space and _ are the same.

For + & % . there are restrictions and complications; not allowed at the start is ":".

Example: abcdefghijklmnopqrstuvwxyz~ !"$'()*,-./0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\^_±×•é

For the first character, a-z are capitalized.

Checking all characters for allowing a page title consisting of p, the character, and q:

paq pbq pcq pdq peq pfq pgq phq piq pjq pkq plq pmq pnq poq ppq pqq prq psq ptq puq pvq pwq pxq pyq pzq [[p{q]] q [[p}q]] p~q pq pq p!q p"q [[p#q]] p$q p%q p&q p'q p(q p)q [[p*q]] p+q p,q p-q p.q p/q p0q p1q p2q p3q p4q p5q p6q p7q p8q p9q [[p:q]] [[p;q]] [[p<q]] p=q [[p>q]] p?q p@q pAq pBq pCq pDq pEq pFq pGq pHq pIq pJq pKq pLq pMq pNq pOq pPq pQq pRq pSq pTq pUq pVq pWq pXq pYq pZq [[p[q]] p\q [[p]q]] p^q p_q p±q p×q péq p•q

Such page titles are allowed for 90 of the 99 characters. They are not allowed for {|}#<>[] and newline, which are not allowed at all in page titles. The automatic procedure seems to show that p*q, p:q and p;q are not allowed either, but this is because the automatic newline feature/bug inserts a newline.

Checking these 90 characters for allowing a page title consisting of 3 of them:

a b c d e f g h i j k l m n o p q r s t u v w x y z [[~~~|~]] [[|]] ! " $ % & ' ( ) + , - . [[12]] 0 1 2 3 4 5 6 7 8 9 = ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \ ^ [[___|_]] ± × é

and testing separately: *** [[:::]] ;;;

Thus such page titles are allowed for 85 of the 90 remaining characters. They are not allowed for ~': and spaces/underscores.

For these 85 characters, checking for allowing even a page title consisting of 86 of them:

a b c d e f g h i j k l m n o p q r s t u v w x y z ! " $ % & ( ) + , - . [[13]] 0 1 2 3 4 5 6 7 8 9 = ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \ ^ ± × é [[••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••|•]]

and testing separately: ************************************************************************************** ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Thus, from these characters, only for • it is not allowed. This is because it takes 3 bytes, so 86 of them exceeds 255 bytes.

For the remaining 84 characters, checking for allowing even a page title consisting of 128 of them:

a b c d e f g h i j k l m n o p q r s t u v w x y z ! " $ % & ( ) + , - . [[14]] 0 1 2 3 4 5 6 7 8 9 = ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \ ^ [[±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±|±]] [[××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××|×]] [[••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••|•]]

and testing separately: ******************************************************************************************************************************** ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Thus, from these characters, it is not allowed for ± × é. This is because they take 2 bytes, so 128 of them exceeds 255 bytes.

The remaining 81 characters allow 255 of them in a page title. Of these 75 can be used in page titles without restrictions and are not affected by the automatic newline feature/bug: a b c d e f g h i j k l m n o p q r s t u v w x y z ! " $ ( ) , - / 0 1 2 3 4 5 6 7 8 9 = ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \ ^

The slash forms the separator for #titleparts, the other 74 characters can freely be used in the up to 25 substrings which can be individually retrieved by #titleparts, with the understanding that when retrieving the first string it capitalizes the first character.

For the period the only limitation is that . and .. are not allowed as substring, so numbers with a dot can be used as or inside substrings.

See Help:Page name.

Relation with Template:Sub[edit]

Template:Sub supports all the 99 characters and more. Comparing {{chrfn|{{{1}}}}} with {{chr|p{{chrfn|{{{1}}}}}|2}}:

01aa 02bb 03cc 04dd 05ee 06ff 07gg 08hh 09 ii 10jj 11kk 12ll 13mm 14nn 15oo 16pp 17qq 18rr 19 ss 20tt 21uu 22vv 23ww 24xx 25yy 26zz 27{{ 28|| 29 }} 30~~ 31 32 33!! 34"" 35#" 36$$ 37%% 38&& 39 '' 40(( 41)) 42*" 43++ 44,, 45-- 46.. 47// 4800 49 11 5022 5133 5244 5355 5466 5577 5688 5799 58:" 59 ;" 60<< 61== 62>> 63?? 64@@ 65AA 66BB 67CC 68DD 69 EE 70FF 71GG 72HH 73II 74JJ 75KK 76LL 77MM 78NN 79 OO 80PP 81QQ 82RR 83SS 84TT 85UU 86VV 87WW 88XX 89 YY 90ZZ 91[[ 92\\ 93]] 94^^ 95__ 96±± 97×× 98éé 99 ••

For the characters 35, 42, 58 and 59 the <nowiki> tags produced by chrfn are internally replaced by a code. The function padleft shows the first character in the four cases:

Thus with chr we get the "unsupported" sign.

However, {{chr|p#|2}}{{chr|p*|2}}{{chr|p:|2}}{{chr|p;|2}} gives #*:;, so chr works for these characters also, just not if they are inside <nowiki> tags.

JavaScript sorting[edit]

See Template:Chrfn/sorting.

See also[edit]