Binary.FromText
Bytes written as text, in Base64 or hexadecimal, turned back into a binary.
Group: Binary and lines. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Binary.FromText(text as nullable text, optional encoding as nullable number) as nullable binary
| Parameter | Type | Description |
|---|---|---|
text | nullable text | The bytes written as text. |
encoding | nullable number optional | BinaryEncoding.Base64 (the default) or BinaryEncoding.Hex (two hexadecimal digits per byte). |
Returns
nullable binary. The bytes; null when the text is null.
Remarks
- Base64 is how bytes travel inside JSON and XML, such as an attachment from a web service. Spaces and line breaks in it are skipped.
- The text must be whole in its encoding: Base64 without its padding (=), or hexadecimal with an odd number of digits, is an error.
Examples
Base64
Binary.FromText("T3Nsbw==")
#binary({79, 115, 108, 111})
Hexadecimal, read as text
Text.FromBinary(Binary.FromText("4F736C6F", BinaryEncoding.Hex))
"Oslo"