Since MySQL's utf8 doesn't support 4 byte characters, I'm looking for a way to detect and eliminate any 4 byte utf8 characters from a string in Ruby. I understand that I can update my table to use utf8m4 but for a couple reasons that's not possible or the desired solution.
Simply encoding the string to ASCII will remove these characters but will also remove all other non-ASCII characters, which is not good.
The following seems to work for me in Ruby 1.9.3:
For example: