Created
March 13, 2015 20:54
-
-
Save sb8244/a44cfa7463c65e89612e to your computer and use it in GitHub Desktop.
Ernie, play nice with Rails!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rails will cause the encoding to slip to ASCII-8BIT for some reason. | |
# This works fine when all rails libraries aren't loaded onto the ernie process | |
class Ernie | |
def self.write_berp(output, ruby) | |
data = BERT.encode(ruby) | |
output.write([data.length].pack("N").force_encoding("utf-8")) | |
output.write(data.force_encoding("utf-8")) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment