diff --git a/lib/vpim/rfc2425.rb b/lib/vpim/rfc2425.rb index f2a6150..9fa1be7 100644 --- a/lib/vpim/rfc2425.rb +++ b/lib/vpim/rfc2425.rb @@ -290,8 +290,9 @@ def Vpim.decode_text_list(value, sep = ',') # :nodoc: # paramtext = *SAFE-CHAR # quoted-string = DQUOTE *QSAFE-CHAR DQUOTE def Vpim.encode_paramtext(value) - case value - when %r{\A#{Bnf::SAFECHAR}*\z} + bin_value = value.dup.force_encoding('ASCII-8BIT') + case bin_value + when %r{\A#{Bnf::SAFECHAR}*\z}n value else raise Vpim::Unencodeable, "paramtext #{value.inspect}" @@ -299,10 +300,11 @@ def Vpim.encode_paramtext(value) end def Vpim.encode_paramvalue(value) - case value - when %r{\A#{Bnf::SAFECHAR}*\z} + bin_value = value.dup.force_encoding('ASCII-8BIT') + case bin_value + when %r{\A#{Bnf::SAFECHAR}*\z}n value - when %r{\A#{Bnf::QSAFECHAR}*\z} + when %r{\A#{Bnf::QSAFECHAR}*\z}n '"' + value + '"' else raise Vpim::Unencodeable, "param-value #{value.inspect}"