File: parser_tools.rb

package info (click to toggle)
ruby-mail 2.8.1%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,704 kB
  • sloc: ruby: 73,709; makefile: 3
file content (15 lines) | stat: -rw-r--r-- 446 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
module Mail
  # Extends each field parser with utility methods.
  module ParserTools #:nodoc:
    # Slice bytes from ASCII-8BIT data and mark as UTF-8.
    if 'string'.respond_to?(:force_encoding)
      def chars(data, from_bytes, to_bytes)
        data.slice(from_bytes..to_bytes).force_encoding(Encoding::UTF_8)
      end
    else
      def chars(data, from_bytes, to_bytes)
        data.slice(from_bytes..to_bytes)
      end
    end
  end
end