Jump to content

HTML Character Entity Decoding


This topic is 3774 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I need to take in HTML and insert it into a field. Is there a custom function that will replace all the HTML Character Entity Encoding?

For example:

name format © = ©

or

numeric format © = ©

Ideally I'd have a substitute function for all of these, I'm hoping one already exists.

Link to comment
Share on other sites

Nevermind.... I just made it myself :) here's what I came up with.

Substitute(HTML;["&nbsp;";" "];["&copy;";"©"];["&reg;";"®"];["&sup2;";"²"];["&sup3;";"³"];["&quot;";"\""];["&amp;";"&"];["&lt;";"<"];["&gt;";">"];["&ndash;";"–"];["&mdash;";"—"];["&lsquo;";"‘"];["&rsquo;";"’"];["&ldquo;";"\“"];["&rdquo;";"\”"];["&bull;";"•"];["&dagger;";"†"];["&Dagger;";"‡"];["&prime;";"′"];["&Prime;";"\″"];["&lsaquo;";"‹"];["&rsaquo;";"›"];["&euro;";"€"];["&trade;";"™"];["&tilde;";"˜"];["&circ;";"ˆ"];["&spades;";"♠"];["&clubs;";"♣"];["&hearts;";"♥"];["&diams;";"♦"];["&loz;";"◊"];["&larr;";"←"];["&rarr;";"→"];["&uarr;";"↑"];["&darr;";"↓"];["&harr;";"↔"];["&not;";"¬"];["&nbsp;";""];["&iexcl;";"¡"];["&cent;";"¢"];["&pound;";"£"];["&curren;";"¤"];["&yen;";"¥"];["&brvbar;";"¦"];["&sect;";"§"];["&uml;";"¨"];["&copy;";"©"];["&ordf;";"ª"];["&laquo;";"«"];["&not;";"¬"];["&shy;";"­"];["&reg;";"®"];["&macr;";"¯"];["&deg;";"°"];["&plusmn;";"±"];["&sup2;";"²"];["&sup3;";"³"];["&acute;";"´"];["&micro;";"µ"];["&para;";"¶"];["&middot;";"•"];["&cedil;";"¸"];["&sup1;";"¹"];["&ordm;";"º"];["&raquo;";"»"];["&frac14;";"¼"];["&frac12;";"½"];["&frac34;";"¾"];["&iquest;";"¿"];["&Agrave;";"À"];["&Aacute;";"Á"];["&Acirc;";"Â"];["&Atilde;";"Ã"];["&Auml;";"Ä"];["&Aring;";"Å"];["&AElig;";"Æ"];["&Ccedil;";"Ç"];["&Egrave;";"È"];["&Eacute;";"É"];["&Ecirc;";"Ê"];["&Euml;";"Ë"];["&Igrave;";"Ì"];["&Iacute;";"Í"];["&Icirc;";"Î"];["&Iuml;";"Ï"];["&ETH;";"Ð"];["&Ntilde;";"Ñ"];["&Ograve;";"Ò"];["&Oacute;";"Ó"];["&Ocirc;";"Ô"];["&Otilde;";"Õ"];["&Ouml;";"Ö"];["&times;";"×"];["&Oslash;";"Ø"];["&Ugrave;";"Ù"];["&Uacute;";"Ú"];["&Ucirc;";"Û"];["&Uml;";"Ü"];["&Yacute;";"Ý"];["&THORN;";"Þ"];["&szlig;";"ß"];["&agrave;";"à"];["&aacute;";"á"];["&acirc;";"â"];["&atilde;";"ã"];["&auml;";"ä"];["&aring;";"å"];["&aelig;";"æ"];["&ccedil;";"ç"];["&egrave;";"è"];["&eacute;";"é"];["&ecirc;";"ê"];["&euml;";"ë"];["&igrave;";"ì"];["&iacute;";"í"];["&icirc;";"î"];["&iuml;";"ï"];["&eth;";"ð"];["&ntilde;";"ñ"];["&ograve;";"ò"];["&oacute;";"ó"];["&ocirc;";"ô"];["&otilde;";"õ"];["&ouml;";"ö"];["&divide;";"÷"];["&oslash;";"ø"];["&ugrave;";"ù"];["&uacute;";"ú"];["&ucirc;";"û"];["&uuml;";"ü"];["&yacute;";"ý"];["&thorn;";"þ"];["&yuml;";"ÿ"];["&#xA0;";""];["&#xA1;";"¡"];["&#xA2;";"¢"];["&#xA3;";"£"];["&#xA4;";"¤"];["&#xA5;";"¥"];["&#xA6;";"¦"];["&#xA7;";"§"];["&#xA8;";"¨"];["&#xA9;";"©"];["&#xAA;";"ª"];["&#xAB;";"«"];["&#xAC;";"¬"];["&#xAD;";"­"];["&#xAE;";"®"];["&#xAF;";"¯"];["&#xB0;";"°"];["&#xB1;";"±"];["&#xB2;";"²"];["&#xB3;";"³"];["&#xB4;";"´"];["&#xB5;";"µ"];["&#xB6;";"¶"];["&#xB7;";"•"];["&#xB8;";"¸"];["&#xB9;";"¹"];["&#xBA;";"º"];["&#xBB;";"»"];["&#xBC;";"¼"];["&#xBD;";"½"];["&#xBE;";"¾"];["&#xBF;";"¿"];["&#xC0;";"À"];["&#xC1;";"Á"];["&#xC2;";"Â"];["&#xC3;";"Ã"];["&#xC4;";"Ä"];["&#xC5;";"Å"];["&#xC6;";"Æ"];["&#xC7;";"Ç"];["&#xC8;";"È"];["&#xC9;";"É"];["&#xCA;";"Ê"];["&#xCB;";"Ë"];["&#xCC;";"Ì"];["&#xCD;";"Í"];["&#xCE;";"Î"];["&#xCF;";"Ï"];["&#xD0;";"Ð"];["&#xD1;";"Ñ"];["&#xD2;";"Ò"];["&#xD3;";"Ó"];["&#xD4;";"Ô"];["&#xD5;";"Õ"];["&#xD6;";"Ö"];["&#xD7;";"×"];["&#xD8;";"Ø"];["&#xD9;";"Ù"];["&#xDA;";"Ú"];["&#xDB;";"Û"];["&#xDC;";"Ü"];["&#xDD;";"Ý"];["&#xDE;";"Þ"];["&#xDF;";"ß"];["&#xE0;";"à"];["&#xE1;";"á"];["&#xE2;";"â"];["&#xE3;";"ã"];["&#xE4;";"ä"];["&#xE5;";"å"];["&#xE6;";"æ"];["&#xE7;";"ç"];["&#xE8;";"è"];["&#xE9;";"é"];["&#xEA;";"ê"];["&#xEB;";"ë"];["&#xEC;";"ì"];["&#xED;";"í"];["&#xEE;";"î"];["&#xEF;";"ï"];["&#xF0;";"ð"];["&#xF1;";"ñ"];["&#xF2;";"ò"];["&#xF3;";"ó"];["&#xF4;";"ô"];["&#xF5;";"õ"];["&#xF6;";"ö"];["&#xF7;";"÷"];["&#xF8;";"ø"];["&#xF9;";"ù"];["&#xFA;";"ú"];["&#xFB;";"û"];["&#xFC;";"ü"];["&#xFD;";"ý"];["&#xFE;";"þ"];["&#xFF;";"ÿ"];[" ";""];["¡";"¡"];["¢";"¢"];["£";"£"];["¤";"¤"];["¥";"¥"];["¦";"¦"];["§";"§"];["¨";"¨"];["©";"©"];["ª";"ª"];["«";"«"];["¬";"¬"];["­";"­"];["®";"®"];["¯";"¯"];["°";"°"];["±";"±"];["²";"²"];["³";"³"];["´";"´"];["µ";"µ"];["¶";"¶"];["·";"•"];["¸";"¸"];["¹";"¹"];["º";"º"];["»";"»"];["¼";"¼"];["½";"½"];["¾";"¾"];["¿";"¿"];["À";"À"];["Á";"Á"];["Â";"Â"];["Ã";"Ã"];["Ä";"Ä"];["Å";"Å"];["Æ";"Æ"];["Ç";"Ç"];["È";"È"];["É";"É"];["Ê";"Ê"];["Ë";"Ë"];["Ì";"Ì"];["Í";"Í"];["Î";"Î"];["Ï";"Ï"];["Ð";"Ð"];["Ñ";"Ñ"];["Ò";"Ò"];["Ó";"Ó"];["Ô";"Ô"];["Õ";"Õ"];["Ö";"Ö"];["×";"×"];["Ø";"Ø"];["Ù";"Ù"];["Ú";"Ú"];["Û";"Û"];["Ü";"Ü"];["Ý";"Ý"];["Þ";"Þ"];["ß";"ß"];["à";"à"];["á";"á"];["â";"â"];["ã";"ã"];["ä";"ä"];["å";"å"];["æ";"æ"];["ç";"ç"];["è";"è"];["é";"é"];["ê";"ê"];["ë";"ë"];["ì";"ì"];["í";"í"];["î";"î"];["ï";"ï"];["ð";"ð"];["ñ";"ñ"];["ò";"ò"];["ó";"ó"];["ô";"ô"];["õ";"õ"];["ö";"ö"];["÷";"÷"];["ø";"ø"];["ù";"ù"];["ú";"ú"];["û";"û"];["ü";"ü"];["ý";"ý"];["þ";"þ"];["ÿ";"ÿ"])

Link to comment
Share on other sites

  • 1 year later...
  • Newbies

Eden Morris,

Thank you very much for posting this custom FileMaker function. I had cause to use it last week, so you have helped me out!

However, I have found a couple of problems:

1. I can't copy and paste the following characters into FileMaker: "♠", "♣", "♥", "♦", "←", "→", "↑", "↓", "↔". They show up as squares, to me.

2. The string "&amp;" needs to be replaced *last*, or it goes wrong. For example, the string "&amp;lt;" should be decoded to "&lt;". In your function, "&amp;" is replaced with "&", so the string becomes "&lt;". But then, later in the same function, "&lt;" is replaced with "<", so the string becomes "<". This is not the correct behaviour. To prevent this from happening, the line ["&amp;";"&"] needs to appear last in the list of substitutions.

But thanks!

Oliver

Link to comment
Share on other sites

This topic is 3774 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.