fix encoding for ~ and | for in Ruby 1.9

This is a work in progress. Attempting to get all the tests passing in ruby 1.9