diff options
author | Mark Longair <mhl@pobox.com> | 2013-05-13 17:50:25 +0100 |
---|---|---|
committer | Mark Longair <mhl@pobox.com> | 2013-05-16 09:06:27 +0100 |
commit | 6b973b1d59b5c384a4ca5a5c0c2c53ad43159ad0 (patch) | |
tree | 0c6fd0676f39429f51eeb858aa265ed795527317 /lib/normalize_string.rb | |
parent | 2d5ddc2d37837cb9ee80931b09dff04cc1120bda (diff) |
Add a helper function for dumping text to disk
This function is useful for investigating problems with
handling of emails, attachments and the related character
encoding issues. It can safely be removed later, but is
currently useful to have for debugging purposes.
Diffstat (limited to 'lib/normalize_string.rb')
-rw-r--r-- | lib/normalize_string.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/normalize_string.rb b/lib/normalize_string.rb index e708a8d96..f02b18ee0 100644 --- a/lib/normalize_string.rb +++ b/lib/normalize_string.rb @@ -73,3 +73,14 @@ def convert_string_to_utf8_or_binary(s, suggested_character_encoding=nil) end result end + +def log_text_details(message, text) + if RUBY_VERSION.to_f >= 1.9 + STDERR.puts "#{message}, we have text: #{text}, of class #{text.class} and encoding #{text.encoding}" + else + STDERR.puts "#{message}, we have text: #{text}, of class #{text.class}" + end + filename = "/var/tmp/#{Digest::MD5.hexdigest(text)}.txt" + File.open(filename, "wb") { |f| f.write text } + STDERR.puts "#{message}, the filename is: #{filename}" +end |