Jump to content

Module:Unicode convert/doc

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Vanisaac (talk | contribs) at 18:30, 11 April 2021 (Using template:mlx for example code). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Usage

Converts Unicode character codes, always given in hexadecimal, to their UTF-8 or UTF-16 representation in upper-case hex or decimal. Can also reverse this for UTF-8. The UTF-16 form will accept and pass through unpaired surrogates e.g. {{#invoke:Unicode convert|getUTF8|D835}} โ†’ D835. The reverse function fromUTF8 accepts multiple characters, and can have both input and output set to decimal.

When using from another module, you may call these functions as e.g. unicodeConvert.getUTF8{ args = {'1F345'} }, without a proper frame object.

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}} 240 159 141 133
{{#invoke:Unicode convert|fromUTF8|F0 9F 8D 85}} 1F345
{{#invoke:Unicode convert|fromUTF8|240 159 141 133}} 127813
{{#invoke:Unicode convert|getUTF16|1F345}} D83C DF45
{{#invoke:Unicode convert|getUTF16|1F345}} 55356 57157

1F345


See also