Nota
O acesso a esta página requer autorização. Pode tentar iniciar sessão ou alterar os diretórios.
O acesso a esta página requer autorização. Pode tentar alterar os diretórios.
Sintaxe
Text.FromBinary(binary as nullable binary, optional encoding as nullable number) as nullable text
Sobre nós
Decodifica dados de um valor binário para um valor de texto usando o tipo de codificação especificado.
-
binary: Os dados binários a serem decodificados. -
encoding: (Opcional) A codificação usada para converter o binário em texto. Use BinaryEncoding.Type para especificar o tipo de codificação. Se esse valor não for especificado, o valor padrão seráBinaryEncoding.Utf8.
Exemplo 1
Codifique texto para binário, produza uma cadeia de caracteres Base64 visível e decodifice-o de volta para o texto.
Utilização
let
originalText = "Testing 1-2-3",
// Default UTF-8 binary
binaryData = Text.ToBinary(originalText),
// Convert binary to viewable Base64 string
encodedText = Binary.ToText(binaryData, BinaryEncoding.Base64),
// Decode back to text
decodedText = Text.FromBinary(binaryData),
result = [
OriginalText = originalText,
BinaryBase64 = encodedText,
DecodedText = decodedText
]
in
result
Output
[
OriginalText = "Testing 1-2-3",
BinaryEncoded = "VGVzdGluZyAxLTItMw==",
DecodedText = "Testing 1-2-3"
]
Exemplo 2
Codifique o texto para binário com uma marca de ordem de bytes (BOM), produza uma cadeia hexadecimal visível e, em seguida, decodifice-a de volta para o texto.
Utilização
let
originalText = "Testing 1-2-3",
// Convert to binary with BOM
binaryData = Text.ToBinary(originalText, TextEncoding.Utf16, true),
// Show binary as hex to demonstrate presence of BOM (fffe)
binaryAsHex = Binary.ToText(binaryData, BinaryEncoding.Hex),
// Decode back to text
decodedText = Text.FromBinary(binaryData, TextEncoding.Utf16),
// Compare original text and decoded text
isIdentical = originalText = decodedText,
result = [
OriginalText = originalText,
BinaryHex = binaryAsHex,
DecodedText = decodedText,
IsIdentical = isIdentical
]
in
result
Output
[
OriginalText = "Testing 1-2-3",
DecodedText = "fffe540065007300740069006e006700200031002d0032002d003300",
DecodedText = "Testing 1-2-3",
IsIdentical = true
]