vendored/puppet/lib/puppet/util/character_encoding.rb in bolt-0.21.1 vs vendored/puppet/lib/puppet/util/character_encoding.rb in bolt-0.21.2
- old
+ new
@@ -70,29 +70,7 @@
Puppet.debug(_("%{value} is not valid UTF-8 and result of overriding encoding would be invalid.") % { value: string.dump })
# Set copy back to its original encoding before returning
return string_copy.force_encoding(original_encoding)
end
end
-
- REPLACEMENT_CHAR_MAP = {
- Encoding::UTF_8 => "\uFFFD",
- Encoding::UTF_16LE => "\xFD\xFF".force_encoding(Encoding::UTF_16LE),
- }
-
- # Given a string, return a copy of that string with any invalid byte
- # sequences in its current encoding replaced with the replacement character
- # "\uFFFD" (UTF-8) if the string is UTF-8 or UTF-16LE, or "?" otherwise.
- # @param string a string to remove invalid byte sequences from
- # @return a copy of string invalid byte sequences replaced by the unicode
- # replacement character or "?" character
- # @note does not modify encoding, but new string will have different bytes
- # from original. Only needed for ruby 1.9.3 support.
- def scrub(string)
- if string.respond_to?(:scrub)
- string.scrub
- else
- replacement_character = REPLACEMENT_CHAR_MAP[string.encoding] || '?'
- string.chars.map { |c| c.valid_encoding? ? c : replacement_character }.join
- end
- end
end
end