Data Encodings

DWScript provides built-in classes for converting between different data representations like Base64, Hex, and URL encoding.

Base64 & Hex

Standard classes provide static Encode and Decode methods for common formats.

var raw := 'Hello World';

var b64 := Base64Encoder.Encode(raw);
PrintLn('Base64: ' + b64);

var hex := HexadecimalEncoder.Encode(raw);
PrintLn('Hex: ' + hex);
Result
Base64: SGVsbG8gV29ybGQ=
Hex: 48656c6c6f20576f726c64

Web Encodings

Always use URLEncodedEncoder when building URLs with parameters.

var param := 'hello world & friends';
var encoded := URLEncodedEncoder.Encode(param);

PrintLn('URL Encoded: ' + encoded);
Result
URL Encoded: hello%20world%20%26%20friends

Related Reference

For a complete list of all supported encoding classes (including Base58, HTML, and XML), see the reference documentation:

On this page