Treatment encode

encoding::encode


Parameters

↳ var encoding: string = "utf-8"
↳ var replace: bool = false

Inputs

⇥ text: Stream<string>

Outputs

↦ data: Stream<byte>


Encodes streamed text with specified encoding.

The incoming string is encoded and outputted into raw bytes. If some characters cannot be encoded into the specified encoding, the behavior is set by replace:

  • false: the character is dropped;
  • true: the character is replaced with coded XML character (such as &#65533;).

The supported encodings and possible values for encoding are defined in the Encoding Standard. If encoding is not recognized, UTF-8 is assumed instead.