Last active
August 16, 2017 08:58
-
-
Save hirakiuc/bcb7991ff3b01405f4f2 to your computer and use it in GitHub Desktop.
StringIO with binary in ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'stringio' | |
| # Create StringIO object from binary data file | |
| StringIO.new(File.binread('pict.jpg'), 'rb') | |
| # Create StringIO object from text data file | |
| StringIO.new(File.read('memo.txt', encoding: Encoding::UTF_8), 'r') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment