HttpEncoder.UrlEncode(Byte[], Int32, Int32) Method

Definition

Encodes an array of characters that are not allowed in a URL into a hexadecimal character-entity equivalent.

protected public:
 virtual cli::array <System::Byte> ^ UrlEncode(cli::array <System::Byte> ^ bytes, int offset, int count);
protected internal virtual byte[] UrlEncode (byte[] bytes, int offset, int count);
abstract member UrlEncode : byte[] * int * int -> byte[]
override this.UrlEncode : byte[] * int * int -> byte[]
Protected Friend Overridable Function UrlEncode (bytes As Byte(), offset As Integer, count As Integer) As Byte()

Parameters

bytes
Byte[]

An array of bytes to encode.

offset
Int32

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

count
Int32

The number of items in the bytes array to encode.

Returns

Byte[]

An array of encoded characters.

Exceptions

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

-or-

count is less than zero or count plus offset is greater than the length of the bytes array.

bytes is null.

Remarks

The UrlEncode method is called by several URL encoding methods in the HttpUtility class.

The UrlEncode method URL-encodes any character that is not in the set of ASCII characters that is considered to be URL-safe. Spaces are encoded as the ASCII "+" character. URL-safe ASCII characters include the ASCII characters (A to Z and a to z), numerals (0 to 9), and some punctuation marks. The following table lists the punctuation marks that are considered URL-safe ASCII characters.

Character Description
- Hyphen
_ Underscore
. Period (dot)
! Exclamation mark
* Asterisk (star)
( Opening parenthesis
) Closing parenthesis

Applies to