rubyregexastral-plane

Regexp in ruby 1.8.7 that will detect a 4-byte Unicode character


Can anyone tell me how I would write a ruby regexp in ruby 1.8.7 to detect the presence of a 4-byte unicode character (specifically the emoji)? I am trying to handle the fact that mysql does not, by default, allow you to store 4-byte emoji unicode characters, now in use by iOS 5.

Thanks!


Solution

  • This appears to match the first two bytes of the four bytes that represent emoji. This is being run in ruby 1.8.7.

    str.match(/\360\237/)