wvanbergen / chunky_png

Read/write access to PNG images in pure Ruby.
https://chunkypng.com
MIT License
1.05k stars 101 forks source link

Wrong encoding for to_blob return string #94

Closed tweksteen closed 9 years ago

tweksteen commented 9 years ago

By default, StringIO will use the external string encoding. In most cases, 'UTF-8' will be used. This creates an issue when using StringIO to generate a blob. (By definition, a blob should use 'ASCII-8BIT'): https://github.com/wvanbergen/chunky_png/blob/dc526b4a/lib/chunky_png/datastream.rb#L177

This could easily be fixed by adding str.set_encoding('ASCII-8BIT') after the string creation.

See point 5 of http://blog.rayapps.com/2013/03/11/7-things-that-can-go-wrong-with-ruby-19-string-encodings/ for further details.

wvanbergen commented 9 years ago

Fixed by #95.

wvanbergen commented 8 years ago

This may have introduced https://github.com/wvanbergen/chunky_png/issues/105