Implement the expensive part of DataOutputStream::writeUTF in JS