HttpUtility.UrlEncodeToBytes Method

Definition

Converts a string or a byte array into an encoded array of bytes.

To encode or decode values outside of a web application, use the WebUtility class.

Overloads

UrlEncodeToBytes(Byte[])

Converts an array of bytes into a URL-encoded array of bytes.

UrlEncodeToBytes(String)

Converts a string into a URL-encoded array of bytes.

UrlEncodeToBytes(String, Encoding)

Converts a string into a URL-encoded array of bytes using the specified encoding object.

UrlEncodeToBytes(Byte[], Int32, Int32)

Converts an array of bytes into a URL-encoded array of bytes, starting at the specified position in the array and continuing for the specified number of bytes.

UrlEncodeToBytes(Byte[])

Converts an array of bytes into a URL-encoded array of bytes.

public:
 static cli::array <System::Byte> ^ UrlEncodeToBytes(cli::array <System::Byte> ^ bytes);
public static byte[] UrlEncodeToBytes (byte[] bytes);
static member UrlEncodeToBytes : byte[] -> byte[]
Public Shared Function UrlEncodeToBytes (bytes As Byte()) As Byte()

Parameters

bytes
Byte[]

The array of bytes to encode.

Returns

Byte[]

An encoded array of bytes.

Remarks

If characters such as blanks and punctuation are passed in an HTTP stream, they might be misinterpreted at the receiving end. URL encoding converts characters that are not allowed in a URL into character-entity equivalents; URL decoding reverses the encoding. For example, when embedded in a block of text to be transmitted in a URL, the characters < and > are encoded as %3c and %3e.

To encode or decode values outside of a web application, use the WebUtility class.

See also

UrlEncodeToBytes(String)

Converts a string into a URL-encoded array of bytes.

public:
 static cli::array <System::Byte> ^ UrlEncodeToBytes(System::String ^ str);
public static byte[] UrlEncodeToBytes (string str);
static member UrlEncodeToBytes : string -> byte[]
Public Shared Function UrlEncodeToBytes (str As String) As Byte()

Parameters

str
String

The string to encode.

Returns

Byte[]

An encoded array of bytes.

Remarks

If characters such as blanks and punctuation are passed in an HTTP stream, they might be misinterpreted at the receiving end. URL encoding converts characters that are not allowed in a URL into character-entity equivalents; URL decoding reverses the encoding. For example, when embedded in a block of text to be transmitted in a URL, the characters < and > are encoded as %3c and %3e.

To encode or decode values outside of a web application, use the WebUtility class.

See also

UrlEncodeToBytes(String, Encoding)

Converts a string into a URL-encoded array of bytes using the specified encoding object.

public:
 static cli::array <System::Byte> ^ UrlEncodeToBytes(System::String ^ str, System::Text::Encoding ^ e);
public static byte[] UrlEncodeToBytes (string str, System.Text.Encoding e);
static member UrlEncodeToBytes : string * System.Text.Encoding -> byte[]
Public Shared Function UrlEncodeToBytes (str As String, e As Encoding) As Byte()

Parameters

str
String

The string to encode

e
Encoding

The Encoding that specifies the encoding scheme.

Returns

Byte[]

An encoded array of bytes.

Remarks

If characters such as blanks and punctuation are passed in an HTTP stream, they might be misinterpreted at the receiving end. URL encoding converts characters that are not allowed in a URL into character-entity equivalents; URL decoding reverses the encoding. For example, when embedded in a block of text to be transmitted in a URL, the characters < and > are encoded as %3c and %3e.

To encode or decode values outside of a web application, use the WebUtility class.

See also

UrlEncodeToBytes(Byte[], Int32, Int32)

Converts an array of bytes into a URL-encoded array of bytes, starting at the specified position in the array and continuing for the specified number of bytes.

public:
 static cli::array <System::Byte> ^ UrlEncodeToBytes(cli::array <System::Byte> ^ bytes, int offset, int count);
public static byte[] UrlEncodeToBytes (byte[] bytes, int offset, int count);
static member UrlEncodeToBytes : byte[] * int * int -> byte[]
Public Shared Function UrlEncodeToBytes (bytes As Byte(), offset As Integer, count As Integer) As Byte()

Parameters

bytes
Byte[]

The array of bytes to encode.

offset
Int32

The position in the byte array at which to begin encoding.

count
Int32

The number of bytes to encode.

Returns

Byte[]

An encoded array of bytes.

Exceptions

bytes is null, but count does not equal 0.

offset is less than 0 or greater than the length of the bytes array.

-or-

count is less than 0, or count + offset is greater than the length of the bytes array.

Remarks

If characters such as blanks and punctuation are passed in an HTTP stream, they might be misinterpreted at the receiving end. URL encoding converts characters that are not allowed in a URL into character-entity equivalents; URL decoding reverses the encoding. For example, when embedded in a block of text to be transmitted in a URL, the characters < and > are encoded as %3c and %3e.

To encode or decode values outside of a web application, use the WebUtility class.

See also

Applies to