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.
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);
}