Given the fact that the presence of absence of the `String#encoding` will not change at run time (the user is either running 1.9+ or they're not...), I think it's preferrable to move the conditional out a level so that it is evaluated at file load time:

``` ruby
if String.method_defined?(:encoding)
  def matching_encoding(string, source)
    string.encode(source.encoding)
  end
else
  def matching_encoding(string, source)
    string
  end
end
```

I haven't bench marked this but I believe this will be a bit faster at runtime by evaluating the conditional once (at file load time) rather than N times (each time `matching_encoding` is called).

On a side note, I have a strong preference for spaces in an arg list--`string, source` rather than `string,source`.  Any reason you chose not to include the space?