mwunsch/rumoji — pull request #2 by jakeboxer (2013-08-14 06:31:20+00:00)
Title: Handle symbol emoji with multiple codepoints

There are (as far as I can tell) 11 emoji that are multi-codepoint. They are:

- :hash: `U+0023 U+20E3`
- :zero: `U+0030 U+20E3`
- :one: `U+0031 U+20E3`
- :two: `U+0032 U+20E3`
- :three: `U+0033 U+20E3`
- :four: `U+0034 U+20E3`
- :five: `U+0035 U+20E3`
- :six: `U+0036 U+20E3`
- :seven: `U+0037 U+20E3`
- :eight: `U+0038 U+20E3`
- :nine: `U+0039 U+20E3`

The existing `SYMBOLS` set only included the first codepoint, which maps to the emoji's ASCII counterpart (`U+0023` is `#`, while `U+0023 U+20E3` is :hash:). This meant the ASCII characters in the set `0123456789#` were being transformed to their cheat-sheet counterparts. Example:

``` ruby
Rumoji.encode("0123456789#")
# => ":zero::one::two::three::four::five::six::seven::eight::nine::hash:"
```

Decoding is also backwards:

``` ruby
Rumoji.decode(":zero::one::two::three::four::five::six::seven::eight::nine::hash:")
# => "0123456789#"
```

This branch fixes it. In order to do so, two things had to happen.

First, I fixed the code points in the `SYMBOLS` set to use the entire emoji codepoint instead of just the ASCII portion.

Second, I replaced the `String#codepoints` call in `Rumoji.decode` with `String#scan`. With `String#codepoints`, something like `U+0023 U+20E3` is interpreted as two separate characters or codepoints, so it's impossible to convert it to the correct emoji on its own. With `String#scan`, we can grab the extra `\u20E3` codepoint when it's there and encode the emoji without accidentally encoding ASCII characters.

/cc @indirect since he introduced me to Rumoji in the first place.