While writing a ColdFusion unit test and using some Emojis, I encountered some strange ColdFusion errors. CF apparently treats the Basic Latin emoji-style KeyKap pound sign like a regular "reserved" pound sign.
The only way I could work around the error was to use CFSaveContent to render the character (without using CFOUTPUT) and then substitute the variable wherever the emoji was to be used.
Adobe may want to consider adding this emoji to their "Special Characters" page.
DEMO
SOURCE
<!--- 20200110 Testing Emojis with ColdFusion, but ran into ColdFusion error when configuring a value for the unit test. | |
CF doesn't like the pound-sign keycap emoji. | |
Using keycap variant https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)#Variants | |
Blog Entry: https://dev.to/gamesover/basic-latin-emoji-style-pound-sign-is-reserved-1he9 | |
Test using TryCF or your own server | |
https://www.trycf.com/gist/8787000b1905babb62ca6da68e6eff8e ---> | |
<fieldset><legend>Outputting as regular strings works:</legend> | |
<p>#️⃣ *️⃣ 0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣</p> | |
</fieldset> | |
<fieldset><legend>Using CFSaveContent works</legend> | |
<p>NOTE: If emoji is within CFOUTPUT, the # emoji will throw an error.</p> | |
<cfsavecontent variable="test">#️⃣ *️⃣ 0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣</cfsavecontent> | |
<cfoutput> | |
<p>#Test#</p> | |
</cfoutput> | |
</fieldset> | |
<fieldset><legend>Using CFSaveContent without CFOUTPUT to define the variable</legend> | |
<cfsavecontent variable="emojiPound">#️⃣</cfsavecontent> | |
<cfset test = "#emojiPound# *️⃣ 0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣"> | |
<cfoutput> | |
<p>#test#</p> | |
</cfoutput> | |
</fieldset> | |
<fieldset><legend>Using CFSET throws a ColdFusion error (in CF2016/2018 and Lucee)</legend> | |
<p>I believe ColdFusion is failing to parse the "#" emoji. If "#" is removed, it works. Do I need to use double-emojis? (j/k)</p> | |
<i style="color:red;">Edit source code and unrem the CFSET statement (CF parsing throws an error)</i> | |
<!--- | |
<cfset test = "#️⃣ *️⃣ 0️⃣ 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣"> | |
---> | |
</fieldset> |
Top comments (0)