https://tenderlovemaking.com/2009/06/26/string-encoding-in-ruby-1-9-c-extensions.html This sounds promising.