# File lib/vcr/structs.rb, line 34
          def try_encode_string(string, encoding)
            return string if encoding.nil? || string.encoding.name == encoding

            # ASCII-8BIT just means binary, so encoding to it is nonsensical
            # and yet "\u00f6".encode("ASCII-8BIT") raises an error.
            # Instead, we'll force encode it (essentially just tagging it as binary)
            return string.force_encoding(encoding) if encoding == "ASCII-8BIT"

            string.encode(encoding)
          rescue EncodingError => e
            struct_type = name.split('::').last.downcase
            warn "VCR: got `#{e.class.name}: #{e.message}` while trying to encode the #{string.encoding.name} " +
                 "#{struct_type} body to the original body encoding (#{encoding}). Consider using the " +
                 "`:preserve_exact_body_bytes` option to work around this."
            return string
          end