We need to use a non-standard unicode character fr...
# compose-web
j
We need to use a non-standard unicode character from a custom font. When we try to use the escape sequence inside
Text()
, for example:
Text("")
, the resultant HTML has the ampersand escaped:

rather than showing the character. How can we use an HTML escape sequence either in a
Text()
or other element function?
a
I think to set raw content you have to use a disposable effect to access the scope element. This is used in the project to set the content of a code block to be some unescaped Kotlin code https://github.com/JetBrains/compose-jb/blob/5d18d0a79dd26a0d5880bdb8c0bb7b8870c9421b/examples/web-landing/src/jsMain/kotlin/com/sample/content/CodeSnippets.kt#L263-L266 although it’s better to use
textContent
instead of
innerText
j
Thanks Adam. I gave that a try and couldn’t get it to work. It’s still escaping the
&
o
Did you try using Kotlin unicode escape instead of HTML?
\uNNNN
j
Thanks @orangy That worked. As soon as I read your answer, I was like 🤦 “of course”.