0

We are replacing all the javascript buttons to custom VF buttons. Have used encodeURIComponent methods in Javascript, unable to find the equivalent salesforce method

Have checked EncodingUtil Class in salesforce but that doesn't seem to solve the purpose ?

Input :

 var uri = "http://w3schools.com/my test.asp?name=ståle&car=saab";
    var res = encodeURIComponent(uri);

Output :

http%3A%2F%2Fw3schools.com%2Fmy%20test.asp%3Fname%3Dst%C3%A5le%26car%3Dsaab

Thanks for the help !

0

Did you check:

String encoded = EncodingUtil.urlEncode(url, 'UTF-8');

Reference: EncodingUtil

Example:

String url = 'http://w3schools.com/my test.asp?name=ståle&car=saab';
String encoded = EncodingUtil.urlEncode(url, 'UTF-8');
System.debug(' Encoded URL: '+encoded);

Result:

Encoded URL: http%3A%2F%2Fw3schools.com%2Fmy+test.asp%3Fname%3Dst%C3%A5le%26car%3Dsaab

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.