String.percent_encode not encoding some emojis correctly (Unable to encode emojis)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 3ddelano

The scenario

I’m making a PUT request using the HTTPRequest node. In the URL I want to include an emoji. For this I have to URL Encode it. But the String.percent_encode() method is not giving correct results.

The problem

Emoji:
String.percent_encode() gives: %ed%a0%bd%ed%b4%94
Desired result is: %F0%9F%94%94

This is only the case for some unicode emojis. For example, for the emoji :heart:, the String.percent_encode gives the desired result of %e2%9d%a4%ef%b8%8f
I’ve tried String.http_escape but it is not the desired result.
Is there any way I can get an emoji to map to the correct URL Encoded version.