This change fixes #530, Net::SSH failure. #49

wants to merge 2 commits into


None yet
2 participants

jhemmelg commented Dec 31, 2011

In the same way that UTF-8 sucks in all ASCII compatible strings and the result is UTF-8, any string that is ASCII-8BIT (BINARY, internally) will suck in anything that is combined with it and the result will be ASCII-8BIT (BINARY).

Funny thing is I came up with a reduction that fails in macruby and 1.9.3, but Net:SSH fails in macuby and works in 1.9.3! Go figure.

Have binary strings (ASCII-8BIT) coerce other strings to it's encoding
This fixes #530, Net:SSH failure.  I have no idea if this interferes
with other gems or general ruby code.  I wouldn't know what to test.

Watson1978 commented Dec 31, 2011

I think this patch is not good.

Following script should return string of UTF-8.
However, this patch return string of ASCII-8BIT.

# -*- coding: utf-8 -*-
str1 = "Happy new year ".force_encoding('BINARY')
str2 = str1.dup
str2.concat('in 世界')
p str2
p str2.encoding


$ ruby19 t.rb
"Happy new year in 世界"


$ macruby t.rb
"Happy new year in \xE4\xB8\x96\xE7\x95\x8C"

Watson1978 commented Feb 15, 2013

This should be fixed with #187.

@Watson1978 Watson1978 closed this Feb 15, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment