Binary.ToText
A binary written as text, in Base64 or hexadecimal, so it can travel where only text may go.
Group: Binary and lines. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
Binary.ToText(binary as binary, optional encoding as nullable number) as nullable text
| Parameter | Type | Description |
|---|---|---|
binary | binary | The bytes to write. |
encoding | nullable number optional | BinaryEncoding.Base64 (the default) or BinaryEncoding.Hex (two hexadecimal digits per byte). |
Returns
nullable text. The bytes as text; null when the binary is null.
Remarks
- This writes the bytes in a code; to read bytes that hold text, use
Text.FromBinary.
Examples
A word in Base64
Binary.ToText(Text.ToBinary("Oslo"))
"T3Nsbw=="
There and back
Text.FromBinary(Binary.FromText(Binary.ToText(Text.ToBinary("Smørbrød"))))
"Smørbrød"