function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Patcs_1Patcs_1 

HTML DECODE function in Apex class

Hi

any body knows how to decode the HTML code into text in apex class.

Let me explain my scenario, I have a api call from external system, In that api call they are encoding the scepical charaters it looks like below.

"firstName": "Ришат",
"lastName": "Гатаулин",

I want to decode this character in to text and store the values in contact object. Currently it is storing with this character. It is not decoding the character.

does anybody have solutions for this.

Thanks in Advance!

 
Best Answer chosen by Patcs_1
Patcs_1Patcs_1
Hi 

Thanks for your reply. I found the answer.

to decode the HTML character in Apex class

we have to use unescapeHtml4()

example :

string str ="Ришат";
string decode  = str.unescapeHtml4();

All Answers

sfdc550sfdc550

Check the link below 
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_restful_encodingUtil.htm

I believe what you're looking for is EncodingUtil.urlEncode().
Patcs_1Patcs_1
Hi 

Thanks for your reply. I found the answer.

to decode the HTML character in Apex class

we have to use unescapeHtml4()

example :

string str ="Ришат";
string decode  = str.unescapeHtml4();
This was selected as the best answer