On Sat, Jun 08, 2013 at 03:08:51PM +0530, Praveen A wrote: > While packaging http_parser.rb, ruby 1.9.1 tests are failing with > /usr/lib/ruby/vendor_ruby/json/common.rb:155:in `encode': "\xC3" on > US-ASCII (Encoding::InvalidByteSequenceError) > in pbuilder. Looking on the web I found > http://stackoverflow.com/questions/12130162/cucumber-fails-with-json-encodinginvalidbytesequenceerror > I have LANG=ml_IN as my default locale and dpkg-buildpackage works > (pbuilder has LANG=C as default). Also ruby 1.8 does not have this > problem. > an interesting discussion I found on this topic > http://www.ruby-forum.com/topic/136955 > I think it is a bug in json library to depend on system locale. Any > ideas how to fix this? > I was thinking of setting up a UTF8 locale in pbuilder, but that > doesn't seem like the right approach. It is not a bug in json. It is caused be the way Ruby 1.9 guesses the encoding of data it reads. You just need to tell explicitly Ruby that those data should be considered as being encoded in UTF-8. The following patch will do the work: --- a/spec/parser_spec.rb +++ b/spec/parser_spec.rb @@ -1,3 +1,7 @@ +if defined? Encoding + Encoding.default_external = "UTF-8" +end + require "spec_helper" require "json" Cheers, Cédric
Attachment:
signature.asc
Description: Digital signature