OpenBI Docs Buy

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
ParameterTypeDescription
textnullable textThe bytes written as text.
encodingnullable 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"

Binary.ToText, Text.FromBinary, #binary.

Last updated · OpenBI Studio 0.3.79