Encoding and Decoding
Encoding is the process of transforming information from one format into another. The opposite operation is called decoding. Encoding is required to represent information that would otherwise cause possible conflicts in a non-encoded form. For example; the < character has a special meaning in XML and cannot be used as-is in XML content. The character has to be encoded using an entity reference.
iXperion provides a variety of encoding and decoding helper vipers. Most vipers are available on the Viper class string and are organized in four categories; base64, bbcode, url and xml encoding.
Converts binary data to and from base64 encoding. This encoding is used to represent binary data in single printable ASCII characters. Typical usage includes encoding binary data in XML documents.
|Smartsite SXML||Copy Code|
convert.tobase64(leasure) => bGVhc3VyZS4=
|convert.frombase64||Decodes a base64 encoded string.|
|convert.tobase64||Convert the given object to a base64 string.|
Transforms a string containing BBCode formatting tags into an XHTML-formatted representation. BBCode is an abbreviation for Bulletin Board Code and is a lightweight markup language used to format posts in message boards. BBCode was devised to provide a safer, easier and more limited way of allowing users to format their messages. BBCode provides a way to avoid cross-site scripting attacks (XSS).
This text contains some BBCode tags, this is [i]italic[/i] and this is [b]bold[/b].
|string.bbdecode||Decodes a string containing BBCode formatting tags to the equivalent XHTML-formatted string representation.|
URL encoding converts characters that are not allowed in a URL into character-entity equivalents; URL decoding reverses the encoding. For example, when embedded in a block of text to be transmitted in a URL, the characters < and > are encoded as %3c and %3e.
|string.urldecode||Decodes a url encoded string.|
|string.urlencode||Convert the given string to a url encoded string.|
XML and derived encodings
XML encoding replaces characters that are not allowed in XML into entity references. Encoding may include predefined entities and numeric entity references. SXML encoding derives from XML encoding and adds more characters to be replaced. HTML encoding converts characters that are not allowed in HTML into character-entity equivalents. HTML adds character entity reference decoding to standard XML decoding.
|string.htmldecode||Returns the HtmlDecoded string of the given string.|
|string.htmlencode||Returns the HtmlEncoded string of the given string.|
|Decodes an SXML encoded string to re-enable SXML processing.|
|Encodes an SXML string to disable SXML processing.|
|string.xmldecode||Returns the XmlDecoded string of the given string.|
|string.xmlencode||Returns the XmlEncoded string of the given string.|
|string.decodeampersand||Decodes ampersand entities in the given string.|
|string.encodeampersand||Encodes ampersand characters to ampersand entities in the given string.|
|string.encodeattribute||Encodes specified data into a valid attribute value. Xml tags are encoded or removed and quotes are encoded.|
|string.encodequotes||Encodes single and double quotes in the given string where single quotes are emitted as numeric entities. Double quote is encoded using " named entity.|
|sxml.disable||Encodes the specified string by disabling both viper and module processing by encoding viper directives and sxml modules.|
The sxml.disable is a unique viper that disables both viper and module processing by only encoding viper directives and sxml modules. Other XML elements are kept intact. The vipers string.sxmldecode and string.sxmlencode have an alias defined on the sxml viper class (sxml.decode and sxml.encode respectivily). The vipers share the same implementation and produce exactly the same output.