static toUTF16(str, littleEndian) {
    const result = new ArrayBuffer(str.length * 2);
    const view = new DataView(result);
    for (let i = 0; i < str.length; ++i) {
      const value = str.charCodeAt(i);
      view.setUint16(/* position= */ i * 2, value, littleEndian);
    }
    return result;
  }
Creates a ArrayBuffer from the given string, converting to UTF-16 encoding.

@param {string} str
@param {boolean} littleEndian
@return {!ArrayBuffer}
@export