{"issue":{"created_at":"2011-08-14T19:46:25Z","state":"closed","updated_at":"2011-12-11T18:56:26Z","comments":3,"user":{"gravatar_id":"5745de469193da7381d6881375a5cc58","id":53660,"url":"https://api.github.com/users/bobthecow","avatar_url":"https://secure.gravatar.com/avatar/5745de469193da7381d6881375a5cc58?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","login":"bobthecow"},"body":"Using Ruby 1.9.x, create a new nanoc site and add the following to `lib/default.rb`:\r\n\r\n~~~ruby\r\nEncoding.default_internal = Encoding::UTF_8\r\n~~~\r\n\r\nThen try to `nanoc compile`. It will fail with an exception about encoding difficulties. The problem appears to be with the underlying PStore implementation, and the way it tries to open files in binary mode. This monkeypatch seems to fix things:\r\n\r\n~~~ruby\r\nclass PStore\r\n  RDWR_ACCESS = \"rb+\"\r\n  RD_ACCESS = \"rb\"\r\n  WR_ACCESS = \"wb\"\r\n\r\n  old_open_and_lock_file = instance_method(:open_and_lock_file)\r\n  define_method(:open_and_lock_file) do |filename, read_only|\r\n    FileUtils.touch(filename) unless File.exists?(filename)\r\n    old_open_and_lock_file.bind(self).(filename, read_only)\r\n  end\r\nend\r\n~~~","assignee":null,"id":1404086,"labels":[{"name":"Bug","color":"ff0000","url":"https://api.github.com/repos/ddfreyne/nanoc/labels/Bug"}],"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":50,"title":"nanoc doesn't play well when default internal encoding is UTF-8","html_url":"https://github.com/ddfreyne/nanoc/issues/50","closed_at":"2011-12-11T18:56:26Z","url":"https://api.github.com/repos/ddfreyne/nanoc/issues/50","milestone":null},"action":"closed"}