Sha256: 6fa91a6889f87bf6b97d25d28119f35cca8c46557ff7f0ef6f4dc7038ca602cf
Contents?: true
Size: 483 Bytes
Versions: 7
Compression:
Stored size: 483 Bytes
Contents
require 'protobuf/field/bytes_field' module Protobuf module Field class StringField < BytesField ENCODING = 'UTF-8'.freeze def decode(bytes) bytes.force_encoding(::Protobuf::Field::StringField::ENCODING) bytes end def encode(value) value.force_encoding(::Protobuf::Field::StringField::ENCODING) string_size = ::Protobuf::Field::VarintField.encode(value.size) string_size << value end end end end
Version data entries
7 entries across 7 versions & 1 rubygems