Sha256: bdf3336dfddff04b471886c3418275293eb6b17fb3acc6f978778e25dc61d454

Contents?: true

Size: 532 Bytes

Versions: 2

Compression:

Stored size: 532 Bytes

Contents

# frozen_string_literal: true

module RASN1
  module Types
    # ASN.1 UTF8 String
    # @author Sylvain Daubert
    class Utf8String < OctetString
      # Utf8String tag value
      TAG = 12

      # Get ASN.1 type
      # @return [String]
      def self.type
        'UTF8String'
      end

      private

      def value_to_der
        @value.to_s.force_encoding('UTF-8').force_encoding('BINARY')
      end

      def der_to_value(der, ber: false)
        super
        @value.force_encoding('UTF-8')
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rasn1-0.7.1 lib/rasn1/types/utf8_string.rb
rasn1-0.7.0 lib/rasn1/types/utf8_string.rb