code: function utf8Substr(str, startInBytes, lengthInBytes) {
  	const strBytes = stringToByteArray(str);
  	const subStrBytes = [];
  	let count = 0;
  
  	for (let i = startInBytes; count < lengthInBytes; i++) {
  		subStrBytes.push(strBytes[i]);
  		count++;
  	}
  
  	return byteArrayToString(subStrBytes);
  
  	// Converts the byte array to a UTF-8 string.
  	// From http://stackoverflow.com/questions/1240408/reading-bytes-from-a-javascript-string?lq=1
  	function byteArrayToString(byteArray) {
  		let str = '';
  		for (let i = 0; i < byteArray.length; i++) {
  			str += byteArray[i] <= 0x7F ? byteArray[i] === 0x25 ? '%25' : // %
  				String.fromCharCode(byteArray[i]) : '%' + byteArray[i].toString(16).toUpperCase();
  		}
  
  		return decodeURIComponent(str);
  	}
  }
docs: Returns a UTF-8 substring.