For Zoho Services only:


I'm actually part of something bigger at Ascent Business Solutions recognized as the top Zoho Premium Solutions Partner in the United Kingdom.

Ascent Business Solutions offer support for smaller technical fixes and projects for larger developments, such as migrating to a ZohoCRM.  A team rather than a one-man-band is always available to ensure seamless progress and address any concerns. You'll find our competitive support rates with flexible, no-expiration bundles at https://ascentbusiness.co.uk/zoho-services/uk-zoho-support.  For larger projects, talk to our experts and receive dedicated support from our hands-on project consultants at https://ascentbusiness.co.uk/zoho-services/zoho-crm-implementation.

The team I manage specializes in coding API integrations between Zoho and third-party finance/commerce suites such as Xero, Shopify, WooCommerce, and eBay; to name but a few.  Our passion lies in creating innovative solutions where others have fallen short as well as working with new businesses, new sectors, and new ideas.  Our success is measured by the growth and ROI we deliver for clients, such as transforming a garden shed hobby into a 250k monthly turnover operation or generating a +60% return in just three days after launch through online payments and a streamlined e-commerce solution, replacing a paper-based system.

If you're looking for a partner who can help you drive growth and success, we'd love to work with you.  You can reach out to us on 0121 392 8140 (UK) or info@ascentbusiness.co.uk.  You can also visit our website at https://ascentbusiness.co.uk.
Zoho Deluge: a HTML Entity Decoder

Zoho Deluge: a HTML Entity Decoder

What?
A very quick article to document a HTML Entity decoder in Zoho Creator.

Why?
Sometimes when receiving data from a third-party, we may receive some strings containing "&" or " " and obviously want to display these as decoded HTML entities. (Zoho if you're listening) Ideally, Zoho may add this to their zoho.encryption namespace such as zoho.encryption.htmldecode(string). But at time of print, it doesn't exist and in the meantime, I've made a function that does this.

How?
Not sure how else to do this but I simply wrote a function in Zoho Creator for each instance that I knew a HTML entity would be submitted. So it doesn't decode every HTML in existence, only the ones I know will happen.

Here's the Zoho Deluge code I use (note that I've put this in a namespace called "DataCleansing", but you can call it whatever you like):
copyraw
string DataCleansing.fn_DecodeHtmlEntities( string p_StringToDecode )
{
	// initialize
	v_StringToDecode = ifnull(p_StringToDecode,"");
	//
	// map string replacements
	m_HtmlEntity = Map();
	m_HtmlEntity.put("&","&");
	m_HtmlEntity.put(" "," ");
	//
	// loop through each of the above replacing where found
	for each  v_HtmlKey in m_HtmlEntity.keys()
	{
		v_StringToDecode = v_StringToDecode.replaceAll(v_HtmlKey, m_HtmlEntity.get(v_HtmlKey), true);
	}
	// 
	// output
	return v_StringToDecode;
}
  1.  string DataCleansing.fn_DecodeHtmlEntities( string p_StringToDecode ) 
  2.  { 
  3.      // initialize 
  4.      v_StringToDecode = ifnull(p_StringToDecode,"")
  5.      // 
  6.      // map string replacements 
  7.      m_HtmlEntity = Map()
  8.      m_HtmlEntity.put("&","&")
  9.      m_HtmlEntity.put(" "," ")
  10.      // 
  11.      // loop through each of the above replacing where found 
  12.      for each  v_HtmlKey in m_HtmlEntity.keys() 
  13.      { 
  14.          v_StringToDecode = v_StringToDecode.replaceAll(v_HtmlKey, m_HtmlEntity.get(v_HtmlKey), true)
  15.      } 
  16.      // 
  17.      // output 
  18.      return v_StringToDecode; 
  19.  } 

Usage:
copyraw
v_TestString = "Father & Sons";
v_DecodedString = thisapp.DataCleansing.fn_DecodeHtmlEntities(v_TestString);
info v_DecodedString;

// yields: Father & Sons
  1.  v_TestString = "Father & Sons"
  2.  v_DecodedString = thisapp.DataCleansing.fn_DecodeHtmlEntities(v_TestString)
  3.  info v_DecodedString; 
  4.   
  5.  // yields: Father & Sons 

A more comprehensive list
copyraw
v_HtmlEntityNames = "amp,lt,gt,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,Uuml,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,OElig,oelig,Scaron,scaron,Yuml,fnof,circ,tilde,Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,Mu,Nu,Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,Omega,alpha,beta,gamma,delta,epsilon,zeta,eta,theta,iota,kappa,lambda,mu,nu,xi,omicron,pi,rho,sigmaf,sigma,tau,upsilon,phi,chi,psi,omega,thetasym,upsih,piv,ensp,emsp,thinsp,zwnj,zwj,lrm,rlm,ndash,mdash,lsquo,rsquo,sbquo,ldquo,rdquo,bdquo,dagger,Dagger,bull,hellip,permil,prime,Prime,lsaquo,rsaquo,oline,frasl,euro,image,weierp,real,trade,alefsym,larr,uarr,rarr,darr,harr,crarr,lArr,uArr,rArr,dArr,hArr,forall,part,exist,empty,nabla,isin,notin,ni,prod,sum,minus,lowast,radic,prop,infin,ang,and,or,cap,cup,int,there4,sim,cong,asymp,ne,equiv,le,ge,sub,sup,nsub,sube,supe,oplus,otimes,perp,sdot,lceil,rceil,lfloor,rfloor,lang,rang,loz,spades,clubs,hearts,diams";
v_HtmlEntityChars = "&,<,>, ,¡,¢,£,¤,¥,¦,§,¨,©,ª,«,¬,­,®,¯,°,±,²,³,´,µ,¶,·,¸,¹,º,»,¼,½,¾,¿,À,Á,Â,Ã,Ä,Å,Æ,Ç,È,É,Ê,Ë,Ì,Í,Î,Ï,Ð,Ñ,Ò,Ó,Ô,Õ,Ö,×,Ø,Ù,Ú,Û,Ü,Ý,Þ,ß,à,á,â,ã,ä,å,æ,ç,è,é,ê,ë,ì,í,î,ï,ð,ñ,ò,ó,ô,õ,ö,÷,ø,ù,ú,û,ü,ý,þ,ÿ,Œ,œ,Š,š,Ÿ,ƒ,ˆ,˜,Α,Β,Γ,Δ,Ε,Ζ,Η,Θ,Ι,Κ,Λ,Μ,Ν,Ξ,Ο,Π,Ρ,Σ,Τ,Υ,Φ,Χ,Ψ,Ω,α,β,γ,δ,ε,ζ,η,θ,ι,κ,λ,μ,ν,ξ,ο,π,ρ,ς,σ,τ,υ,φ,χ,ψ,ω,ϑ,ϒ,ϖ, , , ,‌,‍,‎,‏,–,—,‘,’,‚,“,”,„,†,‡,•,…,‰,′,″,‹,›,‾,⁄,€,ℑ,℘,ℜ,™,ℵ,←,↑,→,↓,↔,↵,⇐,⇑,⇒,⇓,⇔,∀,∂,∃,∅,∇,∈,∉,∋,∏,∑,−,∗,√,∝,∞,∠,∧,∨,∩,∪,∫,∴,∼,≅,≈,≠,≡,≤,≥,⊂,⊃,⊄,⊆,⊇,⊕,⊗,⊥,⋅,⌈,⌉,⌊,⌋,⟨,⟩,◊,♠,♣,♥,♦";
l_HtmlEntityNames = v_HtmlEntityNames.toList();
l_HtmlEntityChars = v_HtmlEntityChars.toList();
//
// add these exceptions (quotes) which wouldn't convert to a list
l_HtmlEntityNames.add("quo");
l_HtmlEntityNames.add("apos");
l_HtmlEntityChars.add("\"");
l_HtmlEntityChars.add("'");
//
// build a map
m_HtmlEntity = Map();
for each index v_EntityIndex in l_HtmlEntityNames
{
	m_HtmlEntity.put("&" + l_HtmlEntityNames.get(v_EntityIndex) + ";", l_HtmlEntityChars.get(v_EntityIndex));
}
//
// loop through list of entities to replace each one in our string
for each  v_HtmlKey in m_HtmlEntity.keys() 
{ 
	v_Test = v_Test.replaceAll(v_HtmlKey, m_HtmlEntity.get(v_HtmlKey), true); 
} 
info v_Test;
// yields: Father & Sons
  1.  v_HtmlEntityNames = "amp,lt,gt,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,Uuml,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,OElig,oelig,Scaron,scaron,Yuml,fnof,circ,tilde,Alpha,Beta,Gamma,Delta,Epsilon,Zeta,Eta,Theta,Iota,Kappa,Lambda,Mu,Nu,Xi,Omicron,Pi,Rho,Sigma,Tau,Upsilon,Phi,Chi,Psi,Omega,alpha,beta,gamma,delta,epsilon,zeta,eta,theta,iota,kappa,lambda,mu,nu,xi,omicron,pi,rho,sigmaf,sigma,tau,upsilon,phi,chi,psi,omega,thetasym,upsih,piv,ensp,emsp,thinsp,zwnj,zwj,lrm,rlm,ndash,mdash,lsquo,rsquo,sbquo,ldquo,rdquo,bdquo,dagger,Dagger,bull,hellip,permil,prime,Prime,lsaquo,rsaquo,oline,frasl,euro,image,weierp,real,trade,alefsym,larr,uarr,rarr,darr,harr,crarr,lArr,uArr,rArr,dArr,hArr,forall,part,exist,empty,nabla,isin,notin,ni,prod,sum,minus,lowast,radic,prop,infin,ang,and,or,cap,cup,int,there4,sim,cong,asymp,ne,equiv,le,ge,sub,sup,nsub,sube,supe,oplus,otimes,perp,sdot,lceil,rceil,lfloor,rfloor,lang,rang,loz,spades,clubs,hearts,diams"
  2.  v_HtmlEntityChars = "&,<,>, ,¡,¢,£,¤,¥,¦,§,¨,©,ª,«,¬,­,®,¯,°,±,²,³,´,µ,,·,¸,¹,º,»,¼,½,¾,¿,À,Á,Â,Ã,Ä,Å,Æ,Ç,È,É,Ê,Ë,Ì,Í,Î,Ï,Ð,Ñ,Ò,Ó,Ô,Õ,Ö,×,Ø,Ù,Ú,Û,Ü,Ý,Þ,ß,à,á,â,ã,ä,å,æ,ç,è,é,ê,ë,ì,í,î,ï,ð,ñ,ò,ó,ô,õ,ö,÷,ø,ù,ú,û,ü,ý,þ,ÿ,Œ,œ,Š,š,Ÿ,ƒ,ˆ,˜,Α,Β,Γ,Δ,Ε,Ζ,Η,Θ,Ι,Κ,Λ,Μ,Ν,Ξ,Ο,Π,Ρ,Σ,Τ,Υ,Φ,Χ,Ψ,Ω,α,β,γ,δ,ε,ζ,η,θ,ι,κ,λ,μ,ν,ξ,ο,π,ρ,ς,σ,τ,υ,φ,χ,ψ,ω,ϑ,ϒ,ϖ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,♦"
  3.  l_HtmlEntityNames = v_HtmlEntityNames.toList()
  4.  l_HtmlEntityChars = v_HtmlEntityChars.toList()
  5.  // 
  6.  // add these exceptions (quotes) which wouldn't convert to a list 
  7.  l_HtmlEntityNames.add("quo")
  8.  l_HtmlEntityNames.add("apos")
  9.  l_HtmlEntityChars.add("\"")
  10.  l_HtmlEntityChars.add("'")
  11.  // 
  12.  // build a map 
  13.  m_HtmlEntity = Map()
  14.  for each index v_EntityIndex in l_HtmlEntityNames 
  15.  { 
  16.      m_HtmlEntity.put("&" + l_HtmlEntityNames.get(v_EntityIndex) + ";", l_HtmlEntityChars.get(v_EntityIndex))
  17.  } 
  18.  // 
  19.  // loop through list of entities to replace each one in our string 
  20.  for each  v_HtmlKey in m_HtmlEntity.keys() 
  21.  { 
  22.      v_Test = v_Test.replaceAll(v_HtmlKey, m_HtmlEntity.get(v_HtmlKey), true)
  23.  } 
  24.  info v_Test; 
  25.  // yields: Father & Sons 
Category: Zoho :: Article: 801

Add comment

Your rating:

Submit

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: Please note that the information provided on this website is intended for informational purposes only and does not represent a warranty. The opinions expressed are those of the author only. We recommend testing any solutions in a development environment before implementing them in production. The articles are based on our good faith efforts and were current at the time of writing, reflecting our practical experience in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Please publish modules in offcanvas position.