How to encode the special characters for correct URL String using apex in Salesforce?

Sample Code:

String strURL = 'www.test.com?name=#1solutions';
strURL = EncodingUtil.urlEncode(strURL, 'UTF-8');

EncodingUtil.urlEncode() encodes the special characters for correct URL String.

Cheers!!!

No comments:

Post a Comment