square / fdoc

Documentation format and verification
Other
379 stars 59 forks source link

Fixed encoding error when dumping files with chinese. #27

Closed abookyun closed 11 years ago

abookyun commented 11 years ago

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:

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! : )

zachmargolis commented 11 years ago

Great! Can you make sure to sign the Individual Contributor License Agreement and let me know?

Also, is there any kind of failing test you can write for that method that was changed?

abookyun commented 11 years ago

Sure. I already finished the form and will try to push failing test later.

zachmargolis commented 11 years ago

@abookyun any update on this?

abookyun commented 11 years ago

We found that the bug is related to some rails environment, keep trying to find it out. Need more time on this ~

zachmargolis commented 11 years ago

@abookyun ok, well I'll close this PR now while it's waiting. Please feel free to re-open when you're ready.