HttpEncoder.UrlEncode(Byte[], Int32, Int32) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將 URL 中不允許的字元陣列編碼為對等的十六進位字元實體。
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()
參數
- bytes
- Byte[]
要編碼的位元組陣列。
- offset
- Int32
bytes 陣列中要開始編碼的位置。
- count
- Int32
bytes 陣列中要編碼之項目的數目。
傳回
編碼字元的陣列。
例外狀況
offset 小於零或大於 bytes 陣列的長度。
-或-
count 小於零或 count 加上 offset 大於 bytes 陣列的長度。
bytes 為 null。
備註
方法 UrlEncode 是由 類別中的 HttpUtility 數個 URL 編碼方法呼叫。
方法 UrlEncode URL 會將不屬於 ASCII 字元集中的任何字元編碼為 URL 安全。 空格會編碼為 ASCII 「 +" 字元。 URL 安全 ASCII 字元包括 (A 到 Z 的 ASCII 字元,以及 z) 、數位 (0 到 9) ,以及一些標點符號。 下表列出被視為 URL 安全 ASCII 字元的標點符號。
| 字元 | 描述 |
|---|---|
| - | Hyphen |
| _ | 底線 |
| . | 句點 (點) |
| ! | 驚嘆號 |
| * | 星號 (星號) |
| ( | 左括弧 |
| ) | 右括弧 |