I recently had the need to store non-latin unicode characters as constants in a method. The chars I wanted were the “box characters”. Essentially, I wanted a method that converted an atom to one of these chars. Below is the only way I could think to do it, but I really don’t like the List.to_string()-ness of it, is there a more idiomatic way to do this?
This, is a good idea… I don’t know why I didn’t think to do just do this. I guess I typically avoid having unicode directly in source for fear that some editor may not respond well to it. But, it’s 2023 so I that fear is probably unfounded. I do like having it in hex because I can edit it without having to copy/paste unicode chars or resorting to char map or other weird os tools.
I hear you on the editor thing. A few community libraries have emojis etc embedded in them, so I’m less concerned these days. If you want to maintain your allergy, you can also use the unicode escape (see String — Elixir v1.16.0-rc.0) - e.g. “\u255A”