function toUtf8Bytes(str) {
  const result = new Uint8Array(str.length);

  for (let i = 0; i < str.length; i += 1) {
    const charCode = str.charCodeAt(i);
    if (charCode < 0 || charCode > 127) {
      return encode(str);
    }
    result[i] = charCode;
  }

  return result;
}
/**
 * Convert string to array of UTF 8 bytes
 *
 * @private
 * @param {string} str String to convert
 * @returns {Uint8Array} Encoded UTF8 chars
 */
Convert string to array of UTF 8 bytes
@private
@param {string} str String to convert
@returns {Uint8Array} Encoded UTF8 chars
Convert string to array of UTF 8 bytes @private @param { string } str String to convert @returns { Uint8Array } Encoded UTF8 chars
function toUtf8Bytes(str) {
  const result = new Uint8Array(str.length);
  for (let i = 0; i < str.length; i += 1) {
    const charCode = str.charCodeAt(i);
    if (charCode < 0 || charCode > 127) {
      return encode(str);
    }
    result[i] = charCode;
  }
  return result;
}
function toUtf8Bytes ( str ) { const result = new Uint8Array ( str . length ) ; for ( let i = 0 ; i < str . length ; i += 1 ) { const charCode = str . charCodeAt ( i ) ; if ( charCode < 0 || charCode > 127 ) { return encode ( str ) ; } result [ i ] = charCode ; } return result ; }
Convert string to array of UTF 8 bytes
 @private
 @param {string} str String to convert
 @returns {Uint8Array} Encoded UTF8 chars
Convert string to array of UTF 8 bytes @private @param { string } str String to convert @returns { Uint8Array } Encoded UTF8 chars