From: Zev Blut Date: 2005-05-27T17:38:34+09:00 Subject: Shift-JIS encoded strings and YAML.load bug Hello, Some of my colleagues discovered a problem loading YAML with Shift-JIS strings when the Ruby's $KCODE is set to Shift-JIS mode. It appears that certain escape sequences are being stripped out of the string when YAML.load is called. This means that the resulting string will not display properly. This happens with both Ruby 1.8.1 and 1.8.2 installs in x86 linux environments. Below is example code showing the problem, assuming my mailer does not kill the characters. You need to run this with a terminal that outputs Shift-JIS. ruby -KS sjis_yaml.rb ---------------------------------------------------------------------- require 'yaml' str1 = "���" str2 = "������" puts "str1: #{str1}" puts "str2: #{str2}" puts "---" puts "str1 yaml: #{str1.to_yaml}" puts "str2 yaml: #{str2.to_yaml}" puts "---" puts "str1 reloaded: #{YAML::load(str1.to_yaml)}" puts "str2 reloaded: #{YAML::load(str2.to_yaml)}" $KCODE="" puts "---" puts "Removed KCODE setting" puts "str1 reloaded: #{YAML::load(str1.to_yaml)}" puts "str2 reloaded: #{YAML::load(str2.to_yaml)}" ---------------------------------------------------------------------- BTW, I am not sure if I should add this as a bug report to the Ruby bug tracker or the Syck bug tracker on Rubyforge. Any guidance on where this should go is appreciated. I will then add this bug report to the proper tracker with the code as an attachment. Thanks, Zev Blut