Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

jhemmelg
Copy link
Contributor

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.

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
Copy link
Member

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

Expect:

$ ruby19 t.rb
"Happy new year in 世界"
#<Encoding:UTF-8>

Result:

$ macruby t.rb
"Happy new year in \xE4\xB8\x96\xE7\x95\x8C"
#<Encoding:ASCII-8BIT>

@Watson1978
Copy link
Member

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants