Permanently protected template

Template:UTF-16

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

0000

Template documentation[view] [edit] [history] [purge]

Usage

{{UTF-16|code point|base=|surrogatesonly=}}

Takes a single Unicode code point and returns the UTF-16 double byte encoding.

Code Point - a Unicode code point scalar value, without the "U+". This template will not properly flag all code points outside of the UTF-32 code space, i.e. any input longer than 8 digits.

Base - template returns UTF-16 double bytes in upper case hexadecimal by default. Base = Dec, Decimal, or 10 outputs decimal values for UTF-16 bytes. Base = LChex, LC16, Lower Case Hex, or Lower Case 16 will output hex codes in lower case.

Surrogatesonly - when yes, template will only return values for code points in the surrogate planes, i.e. those code points where the UTF-16 encoding is different than the scalar value ( > U+FFFF ).

All inputs are case insensitive.

Examples

  • {{UTF-16|110c15}} =
  • {{UTF-16|1bc15}} = D82F DC15
  • {{UTF-16|dc15}} =
  • {{UTF-16|7a5}} = 07A5
  • {{UTF-16|7a5|base=LChex}} = 07a5
  • {{UTF-16|7a5|base=dec}} = 1957
  • {{UTF-16|7a5|surrogatesonly=yes}} =

Note that U+110C15 is too large to be a legal Unicode code point, while U+DC15 is a surrogate code point, which is not legal in isolation, and does not have a UTF-16 value.

Technical

This template makes use of the following sub-templates:

  • {{UTF-16/main}} - Returns the scalar value as 4 digit hex if less than U+10000, and valid Unicode code points as surrogates for larger values.

This template is dependent on the following transcluded templates:

and the magic words / parser functions padleft:, #ifexpr:, #expr:, #switch:, uc:, and lc:.

See also