Sha256: c0520862bf08f3083f9777776739a2c8edf6b71458d035940d7b8e8871f82c1c

Contents?: true

Size: 554 Bytes

Versions: 56

Compression:

Stored size: 554 Bytes

Contents

# frozen_string_literal: true

module Sentry
  module Utils
    module EncodingHelper
      def self.encode_to_utf_8(value)
        if value.encoding != Encoding::UTF_8 && value.respond_to?(:force_encoding)
          value = value.dup.force_encoding(Encoding::UTF_8)
        end

        value = value.scrub unless value.valid_encoding?
        value
      end

      def self.valid_utf_8?(value)
        return true unless value.respond_to?(:force_encoding)

        value.dup.force_encoding(Encoding::UTF_8).valid_encoding?
      end
    end
  end
end

Version data entries

56 entries across 56 versions & 2 rubygems

Version Path
sentry-ruby-core-5.17.3 lib/sentry/utils/encoding_helper.rb
sentry-ruby-5.17.3 lib/sentry/utils/encoding_helper.rb
sentry-ruby-5.17.2 lib/sentry/utils/encoding_helper.rb
sentry-ruby-core-5.17.2 lib/sentry/utils/encoding_helper.rb
sentry-ruby-core-5.17.1 lib/sentry/utils/encoding_helper.rb
sentry-ruby-5.17.1 lib/sentry/utils/encoding_helper.rb
sentry-ruby-5.17.0 lib/sentry/utils/encoding_helper.rb
sentry-ruby-core-5.17.0 lib/sentry/utils/encoding_helper.rb
sentry-ruby-core-5.16.1 lib/sentry/utils/encoding_helper.rb
sentry-ruby-5.16.1 lib/sentry/utils/encoding_helper.rb
sentry-ruby-5.16.0 lib/sentry/utils/encoding_helper.rb
sentry-ruby-core-5.16.0 lib/sentry/utils/encoding_helper.rb
sentry-ruby-5.15.2 lib/sentry/utils/encoding_helper.rb
sentry-ruby-core-5.15.2 lib/sentry/utils/encoding_helper.rb
sentry-ruby-core-5.15.1 lib/sentry/utils/encoding_helper.rb
sentry-ruby-5.15.1 lib/sentry/utils/encoding_helper.rb
sentry-ruby-5.15.0 lib/sentry/utils/encoding_helper.rb
sentry-ruby-core-5.15.0 lib/sentry/utils/encoding_helper.rb
sentry-ruby-5.14.0 lib/sentry/utils/encoding_helper.rb
sentry-ruby-core-5.14.0 lib/sentry/utils/encoding_helper.rb