Module:Unicode convert/doc: Difference between revisions
Appearance
Content deleted Content added
add see also |
→Usage: document fromUTF8 |
||
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. The UTF-16 form will accept and pass through unpaired surrogates e.g. <code>{{#invoke:Unicode convert|getUTF8|D835}}</code> → {{#invoke:Unicode convert|getUTF16|D835}} |
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. <code>{{#invoke:Unicode convert|getUTF8|D835}}</code> → {{#invoke:Unicode convert|getUTF16|D835}}. The reverse function <code>fromUTF8</code> 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. <code>unicodeConvert.getUTF8{ args = {'1F345'} }</code>, without a proper <code>frame</code> object. |
|||
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 12: | Line 14: | ||
|- |
|- |
||
| <code>{{#invoke:Unicode convert|getUTF8|1F345|base=dec}}</code> || {{#invoke:Unicode convert|getUTF8|1F345|base=dec}} |
| <code>{{#invoke:Unicode convert|getUTF8|1F345|base=dec}}</code> || {{#invoke:Unicode convert|getUTF8|1F345|base=dec}} |
||
|- |
|||
| <code>{{#invoke:Unicode convert|fromUTF8|F0 9F 8D 85}}</code> || {{#invoke:Unicode convert|fromUTF8|F0 9F 8D 85 }} |
|||
|- |
|||
| <code>{{#invoke:Unicode convert|fromUTF8|1F345|base=dec|basein=dec}}</code> || {{#invoke:Unicode convert|fromUTF8|240 159 141 133|base=dec|basein=dec}} |
|||
|- |
|- |
||
| <code>{{#invoke:Unicode convert|getUTF16|1F345}}</code> || {{#invoke:Unicode convert|getUTF16|1F345}} |
| <code>{{#invoke:Unicode convert|getUTF16|1F345}}</code> || {{#invoke:Unicode convert|getUTF16|1F345}} |
Revision as of 13:17, 11 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. 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|base=dec}} |
240 159 141 133 |
{{#invoke:Unicode convert|fromUTF8|F0 9F 8D 85}} |
1F345 |
{{#invoke:Unicode convert|fromUTF8|1F345|base=dec|basein=dec}} |
127813 |
{{#invoke:Unicode convert|getUTF16|1F345}} |
D83C DF45 |
{{#invoke:Unicode convert|getUTF16|1F345|base=dec}} |
55356 57157 |
See also