Template:Chr

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search
Template documentation[view] [edit] [history] [purge]

Usage[edit]

{{chr|text|n}} = Returns the n-th character of text ( 1 ≤ n ≤ 499 ), and nothing if n is outside this range, or if n is greater than the length of the string.

Supports a fairly large character set, all 99 characters from Template:Chrfn and more. Returns "˚" on unknown characters. To avoid an automatic newline, the characters *#:; are returned inside <nowiki> tags.

Examples[edit]

  • "{{chr|abc|1}}" gives "a" [1]
  • "{{chr|abc|2}}" gives "b" [2]
  • "{{chr|abc|3}}" gives "c" [3]
  • "{{chr|&sbc|1}}" gives " " [4]
  • "{{chr|&sbc|2}}" gives "b" [5]
  • "{{chr|&sbc|3}}" gives "c" [6]
  • "{{chr|a&sc|1}}" gives "a" [7]
  • "{{chr|a&sc|2}}" gives " " [8]
  • "{{chr|a&sc|3}}" gives "c" [9]
  • "{{chr|ab&s|1}}" gives "a" [10]
  • "{{chr|ab&s|2}}" gives "b" [11]
  • "{{chr|ab&s|3}}" gives " " [12]
  • "{{chr|a&s&s|1}}" gives "a" [13]
  • "{{chr|a&s&s|2}}" gives " " [14]
  • "{{chr|a&s&s|3}}" gives " " [15]
  • "{{chr|&sb&s|1}}" gives " " [16]
  • "{{chr|&sb&s|2}}" gives "b" [17]
  • "{{chr|&sb&s|3}}" gives " " [18]
  • "{{chr|&s&sc|1}}" gives " " [19]
  • "{{chr|&s&sc|2}}" gives " " [20]
  • "{{chr|&s&sc|3}}" gives "c" [21]
  • "{{chr|&s&s&s|1}}" gives " " [22]
  • "{{chr|&s&s&s|2}}" gives " " [23]
  • "{{chr|&s&s&s|3}}" gives " " [24]
  • "{{chr|abc|4}}" gives "" [25]
  • "{{chr|メインページ|2}}" gives "˚" [26]

"{{chr|a&nlc|2}}" gives " " [27]

"{{chr|a c|2}}" gives " " [28]

"{{chr|a

d|2}}{{chr|a

d|3}}"

gives:

"

"

  • "{{chr|123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123|499}}" gives "9" [29]
  • "{{chr|123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123|500}}" gives "" [30]
  • "{{chr|123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123|499}}" gives " " [31]

Template argument size[edit]

A limitation is the maximum template argument size of 2048000 bytes per page.

For calls of this template this depends on the position of the character to be found in the list of supported characters: the later it occurs in the list, the more it is. Also, the higher the index n, the more it is.

Examples:

{{chr|a23456789a12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789a|10}} gives a template argument size of 821 bytes.

{{chr|a23456789ŋ12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789a|10}} gives a template argument size of 7475 bytes.

{{chr|a23456789a12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789a|100}} gives a template argument size of 1742 bytes.

{{chr|a23456789ŋ12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789a|100}} gives a template argument size of 68820 bytes.

See also[edit]