Jump to content

Module:Unicode convert/doc: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Create docs
 
add see also
Line 2: Line 2:
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
== Usage ==
== Usage ==
Converts Unicode character codes, always given in hexadecimal, to their UTF-8 or UTF-16 representation in upper-case hex or decimal.
Converts Unicode character codes, always given in hexadecimal, to their UTF-8 or UTF-16 representation in upper-case hex or decimal. The UTF-16 form will accept and pass through unpaired surrogates e.g. <code>&#123;&#123;#invoke:Unicode convert&#124;getUTF8&#124;D835}}</code> → {{#invoke:Unicode convert|getUTF16|D835}}


To find the character code of a given symbol (in decimal), use e.g. {{ml|ustring|codepoint|\🐱}} → {{#invoke:ustring|codepoint|\🐱}}.
To find the character code of a given symbol (in decimal), use e.g. {{ml|ustring|codepoint|\🐱}} → {{#invoke:ustring|codepoint|\🐱}}.
Line 17: Line 17:
| <code>&#123;&#123;#invoke:Unicode convert&#124;getUTF16&#124;1F345&#124;base=dec}}</code> || {{#invoke:Unicode convert|getUTF16|1F345|base=dec}}
| <code>&#123;&#123;#invoke:Unicode convert&#124;getUTF16&#124;1F345&#124;base=dec}}</code> || {{#invoke:Unicode convert|getUTF16|1F345|base=dec}}
|}
|}

==See also==
{{unicode templates}}


<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |

Revision as of 16:00, 10 April 2021

Usage

Converts Unicode character codes, always given in hexadecimal, to their UTF-8 or UTF-16 representation in upper-case hex or decimal. The UTF-16 form will accept and pass through unpaired surrogates e.g. {{#invoke:Unicode convert|getUTF8|D835}} → D835

To find the character code of a given symbol (in decimal), use e.g. {{#invoke:ustring|codepoint|\🐱}} → 128049.

Code Output
{{#invoke:Unicode convert|getUTF8|1F345}} F0 9F 8D 85
{{#invoke:Unicode convert|getUTF8|1F345|base=dec}} 240 159 141 133
{{#invoke:Unicode convert|getUTF16|1F345}} D83C DF45
{{#invoke:Unicode convert|getUTF16|1F345|base=dec}} 55356 57157

See also