lib/protobuf/field/string_field.rb in protobuffy-3.6.0 vs lib/protobuf/field/string_field.rb in protobuffy-4.0.0
- old
+ new
@@ -6,11 +6,11 @@
##
# Constants
#
- ENCODING = 'UTF-8'.freeze
+ ENCODING = Encoding::UTF_8
##
# Public Instance Methods
#
@@ -23,13 +23,11 @@
def encode(value)
value_to_encode = value.dup
value_to_encode.encode!(::Protobuf::Field::StringField::ENCODING, :invalid => :replace, :undef => :replace, :replace => "")
value_to_encode.force_encoding(::Protobuf::Field::BytesField::BYTES_ENCODING)
- string_size = ::Protobuf::Field::VarintField.encode(value_to_encode.size)
- string_size << value_to_encode
+ "#{::Protobuf::Field::VarintField.encode(value_to_encode.size)}#{value_to_encode}"
end
end
end
end
-