You need to sign in to do that
Don't have an account?
RarLopz
Escape reserved characters
//Following is string i have in custom setting
Ay|a*s'}+ie'\ }5jI2v[ m);pIB}mnO<qT'?/Abzm*Z+}1#@!l$MdsljF$)b|YZ
//I know I can escape the reserved characters in the string by appeending with \
String mystring = 'Ay|a*s'}+ie<b>\</b>'<b>\</b>\ }5jI2v[ m);pIB}mnO<qT<b>\</b>'?/Abzm*Z+}1#@!l$MdsljF$)b|YZ';
system.debug(mystring);
output exactly as original string: Ay|a*s'}+ie'\ }5jI2v[ m);pIB}mnO<qT'?/Abzm*Z+}1#@!l$MdsljF$)b|YZ
However I don't know how to escape the reserved characters when the string is stored in the custom setting. Everything i have tried has failed.
After escaping reserved characters: Ay|a*s'}+ie' }5jI2v[ m);pIB}mnO<qT'?/Abzm*Z+}1#@!l$MdsljF$)b|YZ
Basically in the out put above the \ is missing from the original string. instead of escaping it, the unEscapeJava funtion removed it.
What do i have to do to escape the reserved characters and get the string as it is in Custom Setting ?
Ay|a*s'}+ie'\ }5jI2v[ m);pIB}mnO<qT'?/Abzm*Z+}1#@!l$MdsljF$)b|YZ
//I know I can escape the reserved characters in the string by appeending with \
String mystring = 'Ay|a*s'}+ie<b>\</b>'<b>\</b>\ }5jI2v[ m);pIB}mnO<qT<b>\</b>'?/Abzm*Z+}1#@!l$MdsljF$)b|YZ';
system.debug(mystring);
output exactly as original string: Ay|a*s'}+ie'\ }5jI2v[ m);pIB}mnO<qT'?/Abzm*Z+}1#@!l$MdsljF$)b|YZ
However I don't know how to escape the reserved characters when the string is stored in the custom setting. Everything i have tried has failed.
CustomSetting__c cs = CustomSetting__c.getInstance(); string afterescapingreservedcharacters = cs.SecretAccessKey__c.unescapeJava(); system.debug('After escaping reserved characters: ' +afterescapingreservedcharacters );
After escaping reserved characters: Ay|a*s'}+ie' }5jI2v[ m);pIB}mnO<qT'?/Abzm*Z+}1#@!l$MdsljF$)b|YZ
Basically in the out put above the \ is missing from the original string. instead of escaping it, the unEscapeJava funtion removed it.
What do i have to do to escape the reserved characters and get the string as it is in Custom Setting ?