HttpUtility.UrlDecode 方法

定義

將在 URL 中傳輸的已編碼字串轉換成已解碼的字串。Converts a string that has been encoded for transmission in a URL into a decoded string.

若要編碼或解碼 Web 應用程式之外的值,請使用 WebUtility 類別。To encode or decode values outside of a web application, use the WebUtility class.

多載

UrlDecode(String, Encoding)

使用指定的編碼物件將 URL 編碼的字串轉換成已解碼的字串。Converts a URL-encoded string into a decoded string, using the specified encoding object.

UrlDecode(Byte[], Int32, Int32, Encoding)

使用指定的編碼物件,將 URL 編碼的位元組陣列轉換成已解碼的字串,起點在陣列中的指定位置,延續至指定的位元組數目。Converts a URL-encoded byte array into a decoded string using the specified encoding object, starting at the specified position in the array, and continuing for the specified number of bytes.

UrlDecode(String)

將在 URL 中傳輸的已編碼字串轉換成已解碼的字串。Converts a string that has been encoded for transmission in a URL into a decoded string.

UrlDecode(Byte[], Encoding)

使用指定的解碼物件將 URL 編碼的位元組陣列轉換成已解碼的字串。Converts a URL-encoded byte array into a decoded string using the specified decoding object.

UrlDecode(String, Encoding)

使用指定的編碼物件將 URL 編碼的字串轉換成已解碼的字串。Converts a URL-encoded string into a decoded string, using the specified encoding object.

public:
 static System::String ^ UrlDecode(System::String ^ str, System::Text::Encoding ^ e);
public:
 static System::String ^ UrlDecode(System::String ^ s, System::Text::Encoding ^ e);
public static string? UrlDecode (string? str, System.Text.Encoding e);
public static string UrlDecode (string str, System.Text.Encoding e);
public static string UrlDecode (string s, System.Text.Encoding e);
static member UrlDecode : string * System.Text.Encoding -> string
static member UrlDecode : string * System.Text.Encoding -> string
Public Shared Function UrlDecode (str As String, e As Encoding) As String
Public Shared Function UrlDecode (s As String, e As Encoding) As String

參數

strs
String

要解碼的字串。The string to decode.

e
Encoding

指定解碼配置的 EncodingThe Encoding that specifies the decoding scheme.

傳回

String

已解碼的字串。A decoded string.

備註

如果在 HTTP 資料流程中傳遞空白和標點符號之類的字元,它們可能會在接收端被誤解。If characters such as blanks and punctuation are passed in an HTTP stream, they might be misinterpreted at the receiving end. URL 編碼會將 URL 中不允許的字元轉換成對應的字元實體;URL 解碼會反轉編碼。URL encoding converts characters that are not allowed in a URL into character-entity equivalents; URL decoding reverses the encoding. 例如,內嵌在要在 URL 中傳輸的文字區塊時,字元 < and > 會編碼為% 3c 和% 3e。For example, when embedded in a block of text to be transmitted in a URL, the characters < and > are encoded as %3c and %3e.

若要編碼或解碼 Web 應用程式之外的值,請使用 WebUtility 類別。To encode or decode values outside of a web application, use the WebUtility class.

另請參閱

適用於

UrlDecode(Byte[], Int32, Int32, Encoding)

使用指定的編碼物件,將 URL 編碼的位元組陣列轉換成已解碼的字串,起點在陣列中的指定位置,延續至指定的位元組數目。Converts a URL-encoded byte array into a decoded string using the specified encoding object, starting at the specified position in the array, and continuing for the specified number of bytes.

public:
 static System::String ^ UrlDecode(cli::array <System::Byte> ^ bytes, int offset, int count, System::Text::Encoding ^ e);
public static string? UrlDecode (byte[]? bytes, int offset, int count, System.Text.Encoding e);
public static string UrlDecode (byte[] bytes, int offset, int count, System.Text.Encoding e);
static member UrlDecode : byte[] * int * int * System.Text.Encoding -> string
Public Shared Function UrlDecode (bytes As Byte(), offset As Integer, count As Integer, e As Encoding) As String

參數

bytes
Byte[]

要解碼的位元組陣列。The array of bytes to decode.

offset
Int32

位元組中要開始解碼的位置。The position in the byte to begin decoding.

count
Int32

要解碼的位元組數。The number of bytes to decode.

e
Encoding

Encoding 物件,指定解碼配置。The Encoding object that specifies the decoding scheme.

傳回

String

已解碼的字串。A decoded string.

例外狀況

bytesnull,但 count 不等於 0bytes is null, but count does not equal 0.

offset 小於 0 或大於 bytes 陣列的長度。offset is less than 0 or greater than the length of the bytes array.

-或--or-

count 小於 0,或 count + offset 大於 bytes 陣列的長度。count is less than 0, or count + offset is greater than the length of the bytes array.

備註

如果在 HTTP 資料流程中傳遞空白和標點符號之類的字元,它們可能會在接收端被誤解。If characters such as blanks and punctuation are passed in an HTTP stream, they might be misinterpreted at the receiving end. URL 編碼會將 URL 中不允許的字元轉換成對應的字元實體;URL 解碼會反轉編碼。URL encoding converts characters that are not allowed in a URL into character-entity equivalents; URL decoding reverses the encoding. 例如,內嵌在要在 URL 中傳輸的文字區塊時,字元 < and > 會編碼為% 3c 和% 3e。For example, when embedded in a block of text to be transmitted in a URL the characters < and > are encoded as %3c and %3e.

若要編碼或解碼 Web 應用程式之外的值,請使用 WebUtility 類別。To encode or decode values outside of a web application, use the WebUtility class.

另請參閱

適用於

UrlDecode(String)

將在 URL 中傳輸的已編碼字串轉換成已解碼的字串。Converts a string that has been encoded for transmission in a URL into a decoded string.

public:
 static System::String ^ UrlDecode(System::String ^ str);
public static string? UrlDecode (string? str);
public static string UrlDecode (string str);
static member UrlDecode : string -> string
Public Shared Function UrlDecode (str As String) As String

參數

str
String

要解碼的字串。The string to decode.

傳回

String

已解碼的字串。A decoded string.

備註

如果在 HTTP 資料流程中傳遞空白和標點符號之類的字元,它們可能會在接收端被誤解。If characters such as blanks and punctuation are passed in an HTTP stream, they might be misinterpreted at the receiving end. URL 編碼會將 URL 中不允許的字元轉換成對應的字元實體;URL 解碼會反轉編碼。URL encoding converts characters that are not allowed in a URL into character-entity equivalents; URL decoding reverses the encoding. 例如,內嵌在要在 URL 中傳輸的文字區塊時,字元 < and > 會編碼為% 3c 和% 3e。For example, when embedded in a block of text to be transmitted in a URL, the characters < and > are encoded as %3c and %3e.

若要編碼或解碼 Web 應用程式之外的值,請使用 WebUtility 類別。To encode or decode values outside of a web application, use the WebUtility class.

另請參閱

適用於

UrlDecode(Byte[], Encoding)

使用指定的解碼物件將 URL 編碼的位元組陣列轉換成已解碼的字串。Converts a URL-encoded byte array into a decoded string using the specified decoding object.

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

參數

bytes
Byte[]

要解碼的位元組陣列。The array of bytes to decode.

e
Encoding

指定解碼配置的 EncodingThe Encoding that specifies the decoding scheme.

傳回

String

已解碼的字串。A decoded string.

備註

如果在 HTTP 資料流程中傳遞空白和標點符號之類的字元,它們可能會在接收端被誤解。If characters such as blanks and punctuation are passed in an HTTP stream, they might be misinterpreted at the receiving end. URL 編碼會將 URL 中不允許的字元轉換成對應的字元實體;URL 解碼會反轉編碼。URL encoding converts characters that are not allowed in a URL into character-entity equivalents; URL decoding reverses the encoding. 例如,內嵌在要在 URL 中傳輸的文字區塊時,字元 < and > 會編碼為% 3c 和% 3e。For example, when embedded in a block of text to be transmitted in a URL, the characters < and > are encoded as %3c and %3e.

若要編碼或解碼 Web 應用程式之外的值,請使用 WebUtility 類別。To encode or decode values outside of a web application, use the WebUtility class.

另請參閱

適用於