[SalesForce] Any single method available to escape unicode, single and double quotes

Is there any method similar to "escapeSql" that is available on SalesForce platform. This would be a great feature and will be very useful method for companies whose data is global where Names might contain special characters.

Best Answer

For URL encoding, there is EncodingUtil.urlEncode('StringToEncode', 'UTF-8);


The apex String class offers a number of built in escape*() methods. You would typically need to choose the one that matches what you are doing.

For building dynamic SOQL queries you would typically use escapeSingleQuotes. See SOQL Injection.

There is also escapeUnicode().

What are you intending to do with the escaped values?

You may need to combine several of the built in methods to meet your requirements.