Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@DelawareConsulting
Created December 10, 2015 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DelawareConsulting/12adc0e2cf0c5bf45f22 to your computer and use it in GitHub Desktop.
Save DelawareConsulting/12adc0e2cf0c5bf45f22 to your computer and use it in GitHub Desktop.
def strip_tabs(value)
return "" unless value
#Clean value
if value.kind_of?(String)
value = value.squish!
encoding_options = {
:invalid => :replace, # Replace invalid byte sequences
:undef => :replace, # Replace anything not defined in ISO-8859-1
:replace => '', # Use a blank for those replacements
:UNIVERSAL_NEWLINE_DECORATOR => true # Always break lines with \n
}
value = value.encode(Encoding.find('ISO-8859-1'), encoding_options)
value = value.encode('UTF-8')
end
return value
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment