Модул:encodings/док

Ово је документациона подстраница за Модул:encodings

This module encodes strings into encodings other than UTF-8. Since the wiki software and all its pages and output use UTF-8, it should not be used to display text on the wiki. Rather, it is useful for encoding text in external links, for certain sites that use older encodings. For example, the Catalan IEC dictionary requires input in ISO 8859-1 encoding, and therefore text needs to be converted into this encoding when links to the dictionary are added to entries.

encode[уреди]

encode(text, encoding)

Encodes a given text in the encoding, and returns the resulting string. Scribunto does not allow modules to return invalid UTF-8 text, and replaces any invalid bytes in the output with the U+FFFD REPLACEMENT CHARACTER (�). Since encoded text is bound to contain invalid UTF-8, the output is URL-encoded (percent encoded) before it is returned. This makes sense as the primary use of this function is to encode text for use in URLs.

The module defines a set "encoders" which are able to encode the text in a given encoding. More encoders can be added to the module as necessary.

The encode function can also be invoked from outside Scribunto. The two parameters of the function are given as two unnamed parameters in the invocation.

Utilization[уреди]