views:

733

answers:

1

We are working with the simple backend for the new Rails 2.2 i18n system, and I wanted to know the proper syntax for setting the encoding in a yaml file.

On other words what is the yaml for this xml:

<?xml encoding="UTF-8" ?>
+3  A: 

You can't define the encoding in YAML. But there's also no need to, since, according to the YAML specification, YAML files must be UTF-8 or UTF-16 and include a BOM. This means the encoding is transparent to the YAML and its parsing.

bzlm
this is very similar to JSON, for what that's worth (although JSON also allows UTF-32, doubt anyone uses it)
StaxMan
Actually, according to the JSON RFC, any Unicode format with a BOM is acceptable, and UTF-8 without a BOM. I'm surprised, though, that the JSON and YAML specifications mention this at all, since it's completely irrelevant.
bzlm
The YAML 1.1 spec (which you link to) says that UTF-8 is implied if there is no BOM, and that BOM's should be output only on UTF-16 docs. So the presence of a BOM, and the BOM if it exists, are the only ways to define the encoding.
eksortso