Intelligent parsing of ambiguously encoded meta data.
We cannot trust meta data to be encoded in any particular way,
so we try different encodings.
First we try UTF-8, which is the only sane encoding for non-local
data, even when used in regions where eight bit legacy encodings
are common. The chance of mistakenly parsing non-UTF-8 data as
valid UTF-8 is varies from extremely low (western encodings) to
low for most other encodings.
If the data does not look like UTF-8, we try the suggested encoding,
as parsed out of the commit "encoding" header, or as otherwise
specified by the caller.
If that fails we try the user locale and finally, if that fails we
force to ISO-8859-1, which cannot fail.
[sp: RawParseUtil code by Shawn; RevCommitParseTest by Robin]
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>