DEV Community

James Moberg
James Moberg

Posted on

1 1

Basic Latin Emoji-Style Pound Sign is Reserved

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

View demo with TryCF

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>

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay