Returns a string represented by 2 bytes hex encoding.

1 byte.encode

<byte.encode type='BASE64|UC|UU'>
    <data /> !
</byte.encode>

Exceptions

requires 1 values, received [...]

It has been specified an incorrect number of values.

Remarks

Admits as value any convertible data type to array byte: a string, an array of bytes, a node (of a XML or HTML document), a BLOB (Binary Large Object) or a file.

Example

Print a codified string in BASE64.

Copy
<xsql-script name='byte_encode64_sample1'>
    <body>
        <set name='m_data'>Hello world.</set>
        <println>
            <byte.encode type='BASE64'>
                <m_data />
            </byte.encode>
        </println>
    </body>
</xsql-script>

The result will be:

Copy
*SGVsbG8gd29ybGQu
Example

Print a codified string in UC.

Copy
<xsql-script name='byte_encodeUC_sample1'>
    <body>
        <set name='m_data'>Hello world.</set>
        <println>
            <byte.encode type='UC'>
                <m_data />
            </byte.encode>
        </println>
    </body>
</xsql-script>

The result will be:

Copy
*0C0J85RCCPFWRNFRICPaEHD8
Example

Print a codified string in UU.

Copy
<xsql-script name='byte_encodeUD_sample1'>
    <body>
        <set name='m_data'>Hello world.</set>
        <set name='m_encode'>
            <byte.encode type='UU'>
                <m_data />
            </byte.encode>
        </set>

        <println>Encoded text:<string.nl/><m_encode /></println>

        <set name='m_decode'>
            <byte.decode type='UU'>
                <m_encode />
            </byte.decode>            
        </set>

        <println>Decoded text:<string.nl/><m_decode /></println>
    </body>
</xsql-script>

The result will be:

Copy
Encoded text: 
begin 644 encoder.buf
<![CDATA[,2&5L;&\@=V]R;&0N] ]>

end

Decoded text: 
Hello world.