string->asBytes

Converts a string to bytes.

Target member

Signature

1string->asBytes(encoding::string= ?)

Converts a string to bytes.

string->asBytes is called with member syntax on a receiver value. string->asBytes works with text values. Normalize input at boundaries, escape at output boundaries, and keep encoding calls close to the place where the encoded text is needed.

Parameters

encoding
Optional value of type string. Supply encoding positionally unless the signature shows a keyword form.

Examples

Basic call

1'Ada'->asBytes('UTF-8')
The example shows the receiver and result shape. In templates, apply escaping at the final output boundary.