LogoLogo
2.10.2
2.10.2
  • Introduction
  • Getting started
    • Installation
      • On-premises
      • Azure Market Place
      • AWS Market Place
    • Introduction
      • Reports
      • Services
    • Tutorials
      • Amazon AWS CUR
      • Amazon AWS CUR (Athena)
      • Azure Stack
      • Azure EA
      • Azure CSP
      • Google Cloud
      • VMware vCloud
      • VMware vCenter
    • Releases
      • Upgrading to version 2
      • Archive
  • Reports
    • Accounts
    • Services
    • Summary
    • Budget
  • Services
    • Manage
    • Rates
    • Adjustments
  • ACCOUNTS
    • Budget management
  • Data pipelines
    • Extract
      • Configuration
      • Templates
      • Script basics
      • Parslets
      • Language
        • aws_sign_string
        • basename
        • buffer
        • csv
        • clear
        • discard
        • encode
        • encrypt
        • escape
        • exit_loop
        • foreach
        • generate_jwt
        • get_last_day_of
        • gosub
        • gunzip
        • hash
        • http
        • if
        • json
        • loglevel
        • loop
        • match
        • pause
        • print
        • return
        • save
        • set
        • subroutine
        • terminate
        • unzip
        • uri
        • var
    • Transform
      • Transform Preview
      • Configuration
      • Language
        • aggregate
        • append
        • calculate
        • capitalise
        • convert
        • copy
        • correlate
        • create
        • default
        • delete
        • export
        • finish
        • if
        • import
        • include
        • lowercase
        • normalise
        • option
        • rename
        • replace
        • round
        • service
        • services
        • set
        • split
        • terminate
        • timecolumns
        • timerender
        • timestamp
        • update_service
        • uppercase
        • var
        • where
    • Datasets
    • Lookups
    • Metadata
    • Reports
    • Workflows
  • Administration
    • User management
      • Users
      • Groups
    • Settings
  • Advanced
    • Integrate
      • GUI automation
        • Examples
      • API docs
      • Single Sign On
        • Azure-AD
        • Auth0
        • LDAP
    • Digging deeper
      • Transformer datadate
      • Dataset lifecycle
      • Directories
      • Databases
Powered by GitBook
On this page
  • Syntax
  • Details
  • Example

Was this helpful?

Export as PDF
  1. Data pipelines
  2. Extract
  3. Language

encode

PreviousdiscardNextencrypt

Last updated 5 years ago

Was this helpful?

The encode statement is used to base16 or base64 encode the contents of a variable or a .

Syntax

encode base16|base64varName|{buffer_name}

Details

The encode statement will encode the contents of an existing variable or named buffer, replacing those contents with the encoded version.

The result of encoding the contents will increase their length. With base16 encoding the new length will be double the original. With base64 encoding the new length will be greater than the original but the exact size increase will depend on the contents being encoded.

When encoding a variable, if the size of the result after encoding exceeds the maximum allowable length for a variable value (8095 characters) then the USE script will fail and an error will be returned.

Encoding an empty variable or buffer will produce an empty result

Example

The following script ...

var testdata = "Text to be encoded"

print Encoding a variable ...
# Base16-encode a variable
var encode_me = ${testdata}
encode base16 encode_me
print Encoded base16 result is: ${encode_me}

# Base64-encode a variable
var encode_me = ${testdata}
encode base64 encode_me
print Encoded base64 result is: ${encode_me}

print Encoding a buffer ...
# Base16-encode a buffer
buffer encode_buf = data ${testdata}
encode base16 {encode_buf}
print Encoded base16 result is: {encode_buf}

# Base64-encode a buffer
buffer encode_buf = data ${testdata}
encode base64 {encode_buf}
print Encoded base64 result is: {encode_buf}

... produces the following output:

Encoding a variable ...
Encoded base16 result is: 5465787420746F20626520656E636F646564
Encoded base64 result is: VGV4dCB0byBiZSBlbmNvZGVk
Encoding a buffer ...
Encoded base16 result is: 5465787420746F20626520656E636F646564
Encoded base64 result is: VGV4dCB0byBiZSBlbmNvZGVk
named buffer