Changes

Jump to navigation Jump to search
143 bytes added ,  18:32, 20 June 2023
=Keys=
 
Key encoding is employed by the [[JSON Module]] and the [[CSV Module]] to convert strings to valid element names:
 
* If lax conversion is enabled, invalid characters are replaced with underscores or (when invalid as first character of an element name) prefixed with an underscore. The resulting string may be better readable, but it cannot necessarily be converted back to the original form.
* With lax conversion disabled, a string is encoded to a valid NCName representation:
** An empty string is converted to a single underscore ({{Code|_}}).
** Existing underscores are rewritten to two underscores ({{Code|__}}).
** Characters that are no valid NCName characters are rewritten to an underscore and the character’s four-digit Unicode. For example, the exclamation mark {{Code|?}} is transformed to {{Code|_003f}}.
==convert:encode-key==
|- valign="top"
| '''Summary'''
|Encodes the specified {{Code|$key}} (with the optional {{Code|$lax}} conversion method) to a valid NCName representation, which can be used to create an element node:* An empty string is converted to a single underscore ({{Code|_}}).* Existing underscores are rewritten to two underscores ({{Code|__}}).* Characters that are no valid NCName characters are rewritten to an underscore and the character’s four-digit Unicode. For example, the exclamation mark {{Code|?}} is transformed to {{Code|_003f}}.* If lax conversion is chosen, invalid characters are replaced with underscores or (when invalid as first character of an element name) prefixed with an underscore. The resulting string may be better readable, but it cannot necessarily be converted back to the original form.This encoding is employed by the {{Code|direct}} conversion format in the [[JSON Module]] and the [[CSV Module]].
|- valign="top"
| '''Examples'''
|- valign="top"
| '''Summary'''
|Decodes the specified {{Code|$key}} (with the optional {{Code|$lax}} conversion method) to the original string representation.<br/>Keys supplied to this function are usually can be element names from documents that have been created with by the [[JSON Module]] or [[CSV Module]].
|- valign="top"
| '''Examples'''
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu