decodeURIComponent

Summary

Decodes (unescapes) an individual URI component, such as a query string.

Usage

public string decodeURIComponent(string uriComponent)

Returns

The decoded (unescaped) URI component.

Parameters

uriComponent

The URI component to decode.

Description

Decodes an individual URI "component" such as:

  • Query strings
  • Protocol
  • Hostname
  • etc.

The decoding works by converting characters following the % escape character via UTF-8 decoding.

If the input URI component is invalid, System.Exceptions.InvalidURIException will be thrown. An example of an invalid URI component would be the % escape character being used in isolation without a full escape sequence.

decodeURI vs decodeURIComponent

To understand the differences between decodeURI and decodeURIComponent and to learn the best practices in JS++ when dealing with these methods, please refer to the language guide on decodeURI vs. decodeURIComponent.

Examples

Basic Usage
1
2
3
4
5
import System;
import System.Encoding.URI;
 
string decodedEmail = decodeURIComponent("test%40email.com");
Console.log(decodedEmail); // "test@email.com"
Example of how an exception can be thrown
1
2
3
import System.Encoding.URI;
 
decodeURIComponent("%"); // escape character must include full escape sequence

Share

HTML | BBCode | Direct Link