BinaryFormat.Text is a function in the Power Query M language that reads a text value based on the specified length and encoding. The function returns a binary format that decodes the text using the provided parameters.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
BinaryFormat.Text(
length as any,
optional encoding as nullable number,
) as function
Description
Returns a binary format that reads a text value. The length
specifies the number of bytes to decode, or the binary format of the length that precedes the text. The optional encoding
value specifies the encoding of the text. If the encoding
is not specified, then the encoding is determined from the Unicode byte order marks. If no byte order marks are present, then TextEncoding.Utf8
is used.
Examples
Decode two bytes as ASCII text.
// Output: "AB"
let
binaryData = #binary( {65, 66, 67} ),
textFormat = BinaryFormat.Text( 2, TextEncoding.Ascii )
in
textFormat( binaryData )
Decode ASCII text where the length of the text in bytes appears before the text as a byte.
// Output: "AB"
let
binaryData = #binary( {2, 65, 66} ),
textFormat = BinaryFormat.Text(
BinaryFormat.Byte,
TextEncoding.Ascii
)
in
textFormat( binaryData )
Related functions
Other functions related to BinaryFormat.Text are:
- BinaryFormat.Byte
- BinaryFormat.Choice
- BinaryFormat.Decimal
- BinaryFormat.Double
- BinaryFormat.Length
- BinaryFormat.Null
- BinaryFormat.Single
