Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8a01ad8c507b
Choose a base ref
...
head repository: crystal-lang/crystal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7e9bd700c158
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jul 29, 2016

  1. IO#encoding fix

    Fixes this error:
    
    in /opt/crystal/src/io.cr:875: type must be String, not (IO::EncodingOptions | String)
    
      def encoding : String
    JacobUb authored and Ary Borenszweig committed Jul 29, 2016
    Copy the full SHA
    1d2f46b View commit details
  2. IO#encoding specs

    JacobUb authored and Ary Borenszweig committed Jul 29, 2016
    Copy the full SHA
    7e9bd70 View commit details
Showing with 13 additions and 1 deletion.
  1. +12 −0 spec/std/io/io_spec.cr
  2. +1 −1 src/io.cr
12 changes: 12 additions & 0 deletions spec/std/io/io_spec.cr
Original file line number Diff line number Diff line change
@@ -672,5 +672,17 @@ describe IO do
end
end
end

describe "#encoding" do
it "returns \"UTF-8\" if the encoding is not manually set" do
SimpleMemoryIO.new.encoding.should eq("UTF-8")
end

it "returns the name of the encoding set via #set_encoding" do
io = SimpleMemoryIO.new
io.set_encoding("UTF-16LE")
io.encoding.should eq("UTF-16LE")
end
end
end
end
2 changes: 1 addition & 1 deletion src/io.cr
Original file line number Diff line number Diff line change
@@ -873,7 +873,7 @@ module IO

# Returns this IO's encoding. The default is UTF-8.
def encoding : String
@encoding || "UTF-8"
@encoding.try(&.name) || "UTF-8"
end

# Copy all contents from *src* to *dst*.