HttpUtility.UrlEncodeToBytes Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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[])
- Source:
- HttpUtility.cs
- Source:
- HttpUtility.cs
- Source:
- HttpUtility.cs
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);
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
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
- UrlDecodeToBytes(String)
- How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings
Applies to
UrlEncodeToBytes(String)
- Source:
- HttpUtility.cs
- Source:
- HttpUtility.cs
- Source:
- HttpUtility.cs
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);
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
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
- UrlDecodeToBytes(String)
- How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings
Applies to
UrlEncodeToBytes(String, Encoding)
- Source:
- HttpUtility.cs
- Source:
- HttpUtility.cs
- Source:
- HttpUtility.cs
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);
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.
Returns
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
- UrlDecodeToBytes(String)
- How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings
Applies to
UrlEncodeToBytes(Byte[], Int32, Int32)
- Source:
- HttpUtility.cs
- Source:
- HttpUtility.cs
- Source:
- HttpUtility.cs
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);
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
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
- UrlDecodeToBytes(String)
- How to: Protect Against Script Exploits in a Web Application by Applying HTML Encoding to Strings