# Data Encodings
DWScript provides a consistent API for various data encodings through specialized encoder classes. Each class typically provides `Encode` and `Decode` methods.
## Core Encoders
| Class | Description |
| :--- | :--- |
| `UTF8Encoder` | Standard UTF-8 encoding. |
| `Base64Encoder` | Standard Base64 (RFC 4648). |
| `Base64URIEncoder` | URL-safe Base64 (replaces +/ with -_). |
| `HexadecimalEncoder` | Converts bytes to hex strings. |
| `URLEncodedEncoder` | Standard URL percent-encoding. |
| `HTMLTextEncoder` | Encodes HTML special characters (entities). |
| `Base58Encoder` | Bitcoin-style Base58 encoding. |
## Base64 & Hex Example
```pascal
var s := 'Hello World';
var b64 := Base64Encoder.Encode(s);
PrintLn('Base64: ' + b64);
var raw := Base64Encoder.Decode(b64);
PrintLn('Decoded: ' + raw);
// OUTPUT
// Base64: SGVsbG8gV29ybGQ=
// Decoded: Hello World
```
## URL Encoding Example
```pascal
var url := 'https://example.com/search?q='
+ URLEncodedEncoder.Encode('DWScript & Pascal');
PrintLn(url);
// OUTPUT
// https://example.com/search?q=DWScript%20%26%20Pascal
```
:::info
### Method Syntax
You can also use method syntax for common encodings. For example: `myStr.HTMLEncode` or `myStr.Base64Encode`.
:::
Data Encodings
DWScript provides a consistent API for various data encodings through specialized encoder classes. Each class typically provides Encode and Decode methods.
Core Encoders
Class
Description
UTF8Encoder
Standard UTF-8 encoding.
Base64Encoder
Standard Base64 (RFC 4648).
Base64URIEncoder
URL-safe Base64 (replaces +/ with -_).
HexadecimalEncoder
Converts bytes to hex strings.
URLEncodedEncoder
Standard URL percent-encoding.
HTMLTextEncoder
Encodes HTML special characters (entities).
Base58Encoder
Bitcoin-style Base58 encoding.
Base64 & Hex Example
var s :='Hello World';var b64 := Base64Encoder.Encode(s);
PrintLn('Base64: '+ b64);var raw := Base64Encoder.Decode(b64);
PrintLn('Decoded: '+ raw);
Result
Base64: SGVsbG8gV29ybGQ=
Decoded: Hello World
URL Encoding Example
var url :='https://example.com/search?q='+ URLEncodedEncoder.Encode('DWScript & Pascal');
PrintLn(url);