構文
Text.FromBinary(binary as nullable binary, optional encoding as nullable number) as nullable text
バージョン情報
指定したエンコードの種類を使用して、バイナリ値からテキスト値にデータをデコードします。
-
binary: デコードするバイナリ データ。 -
encoding: (省略可能) バイナリをテキストに変換するために使用されるエンコード。 エンコードの種類を指定するには、 BinaryEncoding.Type を使用します。 この値が指定されていない場合、既定値はBinaryEncoding.Utf8。
例 1
テキストをバイナリにエンコードし、表示可能な Base64 文字列を生成してから、テキストにデコードします。
使用方法
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
アウトプット
[
OriginalText = "Testing 1-2-3",
BinaryEncoded = "VGVzdGluZyAxLTItMw==",
DecodedText = "Testing 1-2-3"
]
例 2
バイト オーダー マーク (BOM) を使用してテキストをバイナリにエンコードし、表示可能な 16 進文字列を生成してから、テキストにデコードします。
使用方法
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
アウトプット
[
OriginalText = "Testing 1-2-3",
DecodedText = "fffe540065007300740069006e006700200031002d0032002d003300",
DecodedText = "Testing 1-2-3",
IsIdentical = true
]