Url Encode and Decode using Magento 2.

You can encode and decode the URL using Magento 2 with native functionality.

Using Url Encode, they encode the base64_encode() for URLs encoding using encode() function.

Using Url Decode, they decode the base64_decode() for URLs decoding.

Both the method have different Interface.
Magento\Framework\Url\EncoderInterface.php used for encode URL.
Magento\Framework\Url\DecoderInterface.php used for decode URL.

You can encode or decode any URL using Magento 2 by the above way.