M
Mikel Lindsaar
In the Mail gem I am doing Regexp's on various strings that arrive,
which can be basically anything (user defined). So I am dup'ing the
string, and forcing the encoding to binary before I do the regexp...
but I am getting this warning:
~/lib/mail/utilities.rb:56: warning: regexp match /.../n against to UTF-8 string
The code that produces that is:
aspecial = %Q|()<>[]:;.\\,"|
control = %Q|\x00-\x1f\x7f-\xff|
PHRASE_UNSAFE = /[#{Regexp.quote aspecial}#{control}]/n
def quote_phrase( str )
if RUBY_VERSION >= '1.9'
string = str.dup
string.force_encoding('ASCII-8BIT')
(PHRASE_UNSAFE === string) ? dquote(str) : str
else
(PHRASE_UNSAFE === str) ? dquote(str) : str
end
end
Any clues?
The specs that generate these errors all pass, so the Regexp is doing
what I intend it to do from what I can see.
which can be basically anything (user defined). So I am dup'ing the
string, and forcing the encoding to binary before I do the regexp...
but I am getting this warning:
~/lib/mail/utilities.rb:56: warning: regexp match /.../n against to UTF-8 string
The code that produces that is:
aspecial = %Q|()<>[]:;.\\,"|
control = %Q|\x00-\x1f\x7f-\xff|
PHRASE_UNSAFE = /[#{Regexp.quote aspecial}#{control}]/n
def quote_phrase( str )
if RUBY_VERSION >= '1.9'
string = str.dup
string.force_encoding('ASCII-8BIT')
(PHRASE_UNSAFE === string) ? dquote(str) : str
else
(PHRASE_UNSAFE === str) ? dquote(str) : str
end
end
Any clues?
The specs that generate these errors all pass, so the Regexp is doing
what I intend it to do from what I can see.