Using special HTML characters in Elm

Dwayne Crooks - Jul 4 '19 - - Dev Community

NOTE: Works for Elm 0.19.

If you attempt to display the copyright symbol using the following:

view = text "©"
Enter fullscreen mode Exit fullscreen mode

Then you'd literally see ©.

In order to get © you need to use Unicode escape characters.

view = text "\u{00A9}"
Enter fullscreen mode Exit fullscreen mode

It's that simple.

If for any reason you mess up the escaping syntax (maybe you forget the curly braces, like a "friend" of mine did ;)) then Elm has your back with this insanely helpful error message.

Unicode escape characters error message

BTW, you can lookup the hex codes for what you need here.

P.S. I needed to figure this out when I had to output a non-breaking space in my Drum Machine project.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player