title | description | ms.assetid | ms.date | ms.topic | keywords | ms.localizationpriority |
---|---|---|---|---|---|---|
Convert between strings and binary data |
This example code shows how to convert between strings and binary data in a Universal Windows Platform (UWP) app. |
AED4C74F-E63B-4980-BB4D-28ACCC1AB58B |
02/08/2017 |
article |
windows 10, uwp, security |
medium |
This example code shows how to convert between strings and binary data in a Universal Windows Platform (UWP) app.
public void ConvertData()
{
// Create a string to convert.
String strIn = "Input String";
// Convert the string to UTF16BE binary data.
IBuffer buffUTF16BE = CryptographicBuffer.ConvertStringToBinary(strIn, BinaryStringEncoding.Utf16BE);
// Convert the string to UTF16LE binary data.
IBuffer buffUTF16LE = CryptographicBuffer.ConvertStringToBinary(strIn, BinaryStringEncoding.Utf16LE);
// Convert the string to UTF8 binary data.
IBuffer buffUTF8 = CryptographicBuffer.ConvertStringToBinary(strIn, BinaryStringEncoding.Utf8);
}