Welcome!
Just as a quick note, you mention "smart contracts" in the question, but give code that looks like Solidity, and also have a Solidity tag in your question, so I assume that the question's focus is Solidity. Different languages may handle Unicode differently, so the answer can change from language to language.
Solidity (v0.7 and higher)
(see hack3r_0m's answer for older versions of Solidity)
From the docs:
While regular string literals can only contain ASCII, Unicode literals – prefixed with the keyword unicode – can contain any valid UTF-8 sequence. They also support the very same escape sequences as regular string literals.
string memory a = unicode"Hello 😃";
This means the code as provided in the question would not work (regular strings are ASCII-encoded), but that by prefacing the string with unicode
, it should work.
Vyper
In Python 3.x the built-in string
type uses utf-8 encoding. As such, our assumption is that Unicode characters should be natively supported in strings. Remix seems to be down for us at the moment, so we don't have a simple way to test this at the moment.