Skip to content

Instantly share code, notes, and snippets.

@dblock
Created September 1, 2011 23:15
Show Gist options
  • Save dblock/1187549 to your computer and use it in GitHub Desktop.
Save dblock/1187549 to your computer and use it in GitHub Desktop.
Spreadhseet encodings monkey-patch, fixes "can't modify a frozen string" error.
# monkey patch frozen string bug, see https://github.com/dblock/spreadsheet/commit/164dcfbb24097728f1a7453702c270107e725b7c
module Spreadsheet
module Encodings
def client string, internal='UTF-16LE'
string = string.dup
string.force_encoding internal
string.encode Spreadsheet.client_encoding
end
def internal string, client=Spreadsheet.client_encoding
string = string.dup
string.force_encoding client
string.encode('UTF-16LE').force_encoding('ASCII-8BIT')
end
def utf8 string, client=Spreadsheet.client_encoding
string = string.dup
string.force_encoding client
string.encode('UTF-8')
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment