Sha256: 51745f57b9c57d292206377e024e47592f6756602b4644129876be401aad3a6b

Contents?: true

Size: 760 Bytes

Versions: 35

Compression:

Stored size: 760 Bytes

Contents

module ExecJS
  # Encodes strings as UTF-8
  module Encoding
    if RUBY_ENGINE == 'jruby' || RUBY_ENGINE == 'rbx'
      # workaround for jruby bug http://jira.codehaus.org/browse/JRUBY-6588
      # workaround for rbx bug https://github.com/rubinius/rubinius/issues/1729
      def encode(string)
        if string.encoding.name == 'ASCII-8BIT'
          data = string.dup
          data.force_encoding('UTF-8')

          unless data.valid_encoding?
            raise ::Encoding::UndefinedConversionError, "Could not encode ASCII-8BIT data #{string.dump} as UTF-8"
          end
        else
          data = string.encode('UTF-8')
        end
        data
      end
    else
      def encode(string)
        string.encode('UTF-8')
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 10 rubygems

Version Path
execjs-2.8.1 lib/execjs/encoding.rb
execjs-2.8.0 lib/execjs/encoding.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/execjs-2.7.0/lib/execjs/encoding.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/encoding.rb
zuora_connect_ui-0.9.2 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/encoding.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/encoding.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/encoding.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/encoding.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/encoding.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/encoding.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/encoding.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/encoding.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/execjs-2.7.0/lib/execjs/encoding.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/execjs-2.7.0/lib/execjs/encoding.rb
arcabouco-0.2.13 vendor/bundle/gems/execjs-2.7.0/lib/execjs/encoding.rb
execjs-2.7.0 lib/execjs/encoding.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/execjs-2.6.0/lib/execjs/encoding.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/execjs-2.6.0/lib/execjs/encoding.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/execjs-2.6.0/lib/execjs/encoding.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/execjs-2.6.0/lib/execjs/encoding.rb