Sha256: 1523b0d2b6835298fa7bbfd165d1a74de1799d7ebf4d3ebfa4adacf0f2bc40ab

Contents?: true

Size: 873 Bytes

Versions: 4

Compression:

Stored size: 873 Bytes

Contents

module Ray
  module TextHelper
    module_function

    if defined? ::Encoding
      # @param [String] string Any string
      # @param [String] enc Name of the encoding of String. Gueseed in 1.9.
      #
      # @return [String] String in Ray's internal encoding
      def internal_string(string, enc = "UTF-8")
        string.encode(InternalEncoding)
      end

      # @param [String] string A string encoded using Ray's internal encoding
      # @param [String] enc Output encoding
      #
      # @return [String] string converted to the asked encoding
      def convert(string, enc = "UTF-8")
        string.encode enc
      end
    else
      def internal_string(string, enc = "UTF-8")
        Iconv.conv(InternalEncoding, enc, string)
      end

      def convert(string, enc = "UTF-8")
        Iconv.conv(enc, InternalEncoding, string)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ray-0.2.1 lib/ray/text_helper.rb
ray-0.2.0 lib/ray/text_helper.rb
ray-0.1.1 lib/ray/text_helper.rb
ray-0.1.0 lib/ray/text_helper.rb