Has anyone attempted to decode HTML entities using AMPscript? For example, I have encoded HTML stored in a data extension:

<p>Dave is great!</p>

I need to use this value in an email but the output is displaying:

<p>Dave is great!</p>

Can AMPscript, or some other feature of the Marketing Cloud, decode the original value before it's called to the email template? Dave needs his credit.

Dave is great!

Dan, I do not think AMPScript has a feature to decode html entities so my advice would be to use the AMPScript replace() function.

Example -

SET @Data = "&lt;p&gt;Dave is great! &lt;/p&gt;"

SET @Data1 = Replace(Replace(@Data,"&lt;","<"),"&gt;",">")

As stated by others, there is nothing native in Ampscript for this. I am not sure, but potentially using something with the "Format" Ampscript may be a possibility, depending on how extensive the connection with C# string formatting is. I have never used this so I am not sure.

Outside that I would look at using SSJS using HTMLEncode or HTMLDecode as SSJS and AmpScript can interact to a level inside Exact Target. I am not sure if this will work if coded inside an email, but you could try to create a SSJS interaction(need to call Help Desk to add into your account) to pull the info and correctly encode/decode and then fill this now correct info into an AMPScript variable in email using the AMPscript Web API capabilities.

  • Those functions decode HTML entities? – Adam Spriggs Jun 21 '15 at 22:25
  • I misread some I believe. He may need to use Replace to decode the less then and greater then into the symbols first then use that ContentArea so it reads it as code and not just a text string when displaying. – Gortonington Jun 22 '15 at 11:07
  • The TreatAsContent functions will force AMPScript to be evaluated inside the content block. As far as I know, it doesn't have anything to do with HTML entity encoding/decoding. Can you clarify your answer with an example perhaps? – Adam Spriggs Jun 22 '15 at 16:41
  • After looking at it a bit more thoroughly, I completely misread the question. I thought the issue was that the code was not rendering, not that a solution to decode the HTML was needed from the DE. I am going to edit my answer to include relevant information – Gortonington Jun 23 '15 at 13:25

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.