How to use Unicode characters in labels and text nodes


I’m writing this here as a reminder for myself, and perhaps also as help for others:

Today I got a question from our translators how to use a zero-width space character in Defold. A zero-width space character isn’t visible but it is respected by the line-break option in Defold labels and GUI text nodes.

You can usually paste your unicode characters as is into a string and set that on a label or text node, but in the case of a zero-width space character that isn’t very convenient since it can’t be seen. What you can do instead is to use the UTF-8 encoded representation of the zero-width space character. A zero-width space is Unicode \u200B which when encoded to UTF-8 becomes:


You can try this yourself using an online UTF-8 encoder/decoder. Copy the Unicode symbol and paste it and you’ll get the UTF-8 encoded equivalent (note that you must use decimal, not hexadecimal numbers). This does of course work for any Unicode symbol:

‡ encodes to \226\128\161
™encodes to \226\132\162
and so on

Remember that you also need to make sure that the character exists in the font for it to display properly and that you have either added the character you wish to use in the Extra Characters field of the font or checked the All Chars checkbox!