encoding/unicode: new BOM policy for standard UTF-16.

The current options did not allow the UTF-16 encoding to be specified
accoding to RFC recommendations (as well as common practice). Added
UseBOM policy to fix this.

Implemented BOM policy internally as a bitmask of options. This makes
the semantics of the three options clearer (at least to me) at first
glance.

UTF16 now also assigns MIB constants to UTF-16 encodings, if possible.
Note that some configurations map to the same MIB identifier. RFC 2781
has requirements and recommendations. Some of the "configurations"
are merely recommendations, so multiple configurations could match.

Change-Id: Id2da4293b054cdd774c876d288127259afccffd1
Reviewed-on: https://go-review.googlesource.com/8395
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2 files changed