-
-
Save DelawareConsulting/12adc0e2cf0c5bf45f22 to your computer and use it in GitHub Desktop.
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
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