I’ve confirmed with WireShark that Safari is sending valid UTF-8 (11110000 10011111 10011000 10010011 or hex: f0 9f 98 93, which gives the Unicode codepoint U+1F613 😓). So I know it’s Node’s issue receiving and processing it.
This is probably one of the reasons that Google Chrome doesn’t support Emoji - check out this page in Chrome, then view it in Safari to see what you’re missing! (Chrome uses the V8 engine.)
You could base64-encode your payload, or simply
it. Or you could trim anything outside of UCS. Or you could do a custom
encode/unencode such as this one. I’m not really happy with
any of these, so I’m still looking for a solution.
In the end I implemented this (see below) on the client
side, and left the data encoded server side. All clients are responsible
encode()ing characters when sending, and
receiving (whether that be via websockets or HTTP). It seems to work
quite well and doesn’t massively inflate the content-size for ASCII and
possibly more, so I’m relatively happy with it.
Besides it’s midnight and I need to get some sleep.