Sha256: 0e8a6cfc903c2442b9bac6f078df71c5f644927a13a32bbaecd8112e572444fd
Contents?: true
Size: 805 Bytes
Versions: 18
Compression:
Stored size: 805 Bytes
Contents
# Allows any object (if supported) to have all related # strings encoded in place to UTF-8. module UTF8Encoding module ObjectSupport # Recursively ensure the correct encoding is being used: def ensure_utf8_object!(object) case object when String ensure_utf8!(object) when Hash ensure_utf8_hash!(object) when Array ensure_utf8_array!(object) else object end end # Ensures all values of the given `hash` are UTF-8, where possible. def ensure_utf8_hash!(hash) hash.each_value { |value| ensure_utf8_object!(value) } end # Ensures all elements of the given `array` are UTF-8, where possible. def ensure_utf8_array!(array) array.each { |element| ensure_utf8_object!(element) } end end end
Version data entries
18 entries across 18 versions & 1 rubygems