http://zorba.io/modules/base64

Description

Before using any of the functions below please remember to import the module namespace:

import module namespace base64 = "http://zorba.io/modules/base64";

Base64 encoding and decoding.

Module code

Here is the actual XQuery module code.

Authors

Matthias Brantner

Version Declaration

jsoniq version "1.0" encoding "utf-8";

Namespaces

base64http://zorba.io/modules/base64
verhttp://zorba.io/options/versioning
zerrhttp://zorba.io/errors

Function Summary

decode($base64 as base64Binary) as string external

Decode a base64Binary.

decode($base64 as base64Binary, $encoding as string) as string external

Decode a base64Binary.

encode($string as string) as base64Binary external

Encode a string as base64Binary.

Functions

decode#1

declare function base64:decode(
    $base64 as base64Binary
) as string external

Decode a base64Binary.

The function assumes that the content after decoding is valid UTF-8.

Parameters

  • $base64

    The base64Binary item to decode

Returns

  • string

    the base64-decoded value as string

Errors

  • zerr:ZOSE0006

    if $base64 contains invalid base-64 data.

decode#2

declare function base64:decode(
    $base64 as base64Binary,
    $encoding as string
) as string external

Decode a base64Binary.

The function assumes that the content after decoding has the given encoding.

Parameters

  • $base64

    The base64Binary item to decode

  • $encoding

    The encoding of the string after base64-decoding it. The encoding parameter is case insensitive.

Returns

  • string

    the base64-decoded value as a string

Errors

  • zerr:ZXQP0006

    if the given encoding is invalid or not supported. "ASCII" and "UTF-8" are guaranteed to be supported; other encodings may be supported depending on the installation.

  • zerr:ZOSE0006

    if $base64 contains invalid base-64 data.

encode#1

declare function base64:encode(
    $string as string
) as base64Binary external

Encode a string as base64Binary.

Parameters

  • $string

    The item whose string-value should be encoded

Returns

  • base64Binary

    the base64-encoded string-value of the item parameter