How to get YAML in Ruby from version 1.9.3 to discard ASCII-8Bit strings as strings?

Here's the problem: I can have UTF-8 strings, and I can have strings that are US-ASCII. Regardless of the encoding, I would like YAML.dump (str) to actually delete String objects instead of these useless !binary objects, as the example shows.

Is there a flag or something that I don't see to get YAML.dump () to do the right thing?

Ruby 1.9.1 example

 YAML::VERSION # "0.60" a = "foo" # => "foo" a.force_encoding("BINARY") # => "foo" YAML.dump(a) # => "--- foo\n" 

Ruby 1.9.3 example

 YAML::VERSION # "1.2.2" a = "foo" # => "foo" a.force_encoding("BINARY") # => "foo" YAML.dump(a) # => "--- !binary |-\n Zm9v\n" 

Update: got my own answer

 YAML::ENGINE.yamler='syck' YAML.dump(a) # => "--- foo\n" 

So, it seems that using the old Yamler mechanism, the old behavior worked.

+8
string ruby binary yaml utf-8
source share
1 answer

Update: got my own answer

 YAML::ENGINE.yamler='syck' YAML.dump(a) # => "--- foo\n" 
+4
source share

All Articles