Notitie
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen u aan te melden of de directory te wijzigen.
Voor toegang tot deze pagina is autorisatie vereist. U kunt proberen de mappen te wijzigen.
Syntaxis
Text.FromBinary(binary as nullable binary, optional encoding as nullable number) as nullable text
Over
Ontsleutelt gegevens van een binaire waarde naar een tekstwaarde met behulp van het opgegeven coderingstype.
-
binary: De binaire gegevens die moeten worden gedecodeerd. -
encoding: (Optioneel) De codering die wordt gebruikt om het binaire bestand te converteren naar tekst. Hiermee BinaryEncoding.Type geeft u het type codering op. Als deze waarde niet is opgegeven, isBinaryEncoding.Utf8de standaardwaarde .
Voorbeeld 1
Codeer tekst naar binair, produceert een bekijkbare Base64-tekenreeks en decodert deze terug naar tekst.
Gebruik
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
Uitvoer
[
OriginalText = "Testing 1-2-3",
BinaryEncoded = "VGVzdGluZyAxLTItMw==",
DecodedText = "Testing 1-2-3"
]
Voorbeeld 2
Codeer tekst naar binair met een Byte Order Mark (BOM), produceert een weergavebare hexadecimale tekenreeks en decodert deze vervolgens terug naar tekst.
Gebruik
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
Uitvoer
[
OriginalText = "Testing 1-2-3",
DecodedText = "fffe540065007300740069006e006700200031002d0032002d003300",
DecodedText = "Testing 1-2-3",
IsIdentical = true
]