CryptographicBuffer.ConvertStringToBinary 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將字串轉換成編碼的緩衝區。
public:
static IBuffer ^ ConvertStringToBinary(Platform::String ^ value, BinaryStringEncoding encoding);
static IBuffer ConvertStringToBinary(winrt::hstring const& value, BinaryStringEncoding const& encoding);
public static IBuffer ConvertStringToBinary(string value, BinaryStringEncoding encoding);
function convertStringToBinary(value, encoding)
Public Shared Function ConvertStringToBinary (value As String, encoding As BinaryStringEncoding) As IBuffer
參數
- value
-
String
Platform::String
winrt::hstring
要編碼的字串。
- encoding
- BinaryStringEncoding
編碼格式。
傳回
編碼的緩衝區。
範例
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);
}