Runtime: use our own conversion functions between UTF-16 and UTF-8.

On several browsers (Chrome, for instance), this is much faster than the
hack we used previously.

This also allows us to replace invalid bytes/codepoints by \ufffd
(Unicode "replacement character") instead of performing no conversion
for incorrect strings.