%dw 2.0
import * from dw::util::Coercions
output application/dw
---
{
'UTF-16Ex': toBinary("DW", "UTF-16"),
'utf16Ex': toBinary("DW", "utf16"),
'UnicodeBigEx': toBinary("DW", "UnicodeBig"),
'UTF-32Ex': toBinary("DW", "UTF-32"),
'UTF_32Ex': toBinary("DW", "UTF_32")
}
toBinary
toBinary(str: String, encoding: String): Binary
Transform a String
value into a Binary
value
using the specified encoding.
Introduced in DataWeave version 2.4.0.
Parameters
Name | Description |
---|---|
|
The |
|
The encoding to apply to the |
Example
This example shows how toBinary
behaves with different inputs.
It produces output in the application/dw
format.