Fix FWNX-918 and the crash reported recently in FWNX-114

Both of these bugs involve the encoding converters, and the actual fix for
FWNX-918 is in the encoding converter C# code.  Since that's stored in hg
instead of git, the fix is harder to review, but the diffs are available
upon request.

Change-Id: I89fa15f58fdd583ca568148779961389c0c7e86f