Skip to content

v2.8.6

Compare
Choose a tag to compare
@localshred localshred released this 17 Sep 15:37
· 882 commits to master since this release

Fixes string/byte encoding issue when unicode characters present. Reported by @foxban. This was also backported to v2.7.12. [#120, 067a3e3]

Before this change, if a string or bytes field contained a unicode
character, that field was effectively corrupted from its source value
after the proto was encoded. Also, subsequent calls to encode returned null bytes.

resource = Test::Resource.new(:name => "\u20ac") # => {:name=>"€"}
resource.encode #=> valid encoding
resource.name # => "\xE2\x82\xAC"
resource.encode #=> "\n\u0000"
resource.name # => ""

It should be noted this behavior is not present when the string
contains characters that fall inside the normal ascii range.