square/fdoc — pull request #27 by abookyun (2013-04-30 19:36:34+00:00)
Title: Fixed encoding error when dumping files with chinese.

Recently, we've been trying to integrate `fdoc` into our project, but unfortunately encountered a YAML exception related to encodings.

It happens when we have a `fdoc` schema in Chinese and run spec in scaffolding mode.

To make it clear, it could also be reproduced by following codes:

```ruby
schema = { "中文" => "編碼" }
file = File.open("some/where/to/test.yaml", "w")
YAML.dump(schema, file)
```

which will throw `Encoding::UndefinedConversionError: "\xE4" from ASCII-8BIT to UTF-8` exception.

This is definitely related to some encoding issues of `psych` and `yaml`, and our ruby versions is `ruby 1.9.3p374 (2013-01-15 revision 38858) [x86_64-darwin12.2.1]`.

Before these issue are fixed in those libraries, we find a workaround to it by simply replacing `YAML.dump(schema, file)` with `schema.to_yaml` and `file.write`.

I hope this help! : )