(PUP-1389) Embed the extra NULL within the string
Previously, we were appending a NULL to the wide encoded string to work around
a ruby bug fixed in 2.1.
However, we were calling String#strip, which makes a copy of the string, and
in the process only preserves the first NULL.
This commit embeds a NULL within the string itself, e.g. "bob\0". Since the
NULL is part of the string data, ruby will preserve it.
Also, String#+ cannot combine strings with different encodings,
e.g. "a".encode('UTF-16LE') + "\0" results in:
incompatible character encodings: UTF-16LE and US-ASCII
which is why we need to encode the terminator. The actual message depends on
the default encoding, e.g. US-ASCII, UTF-8.