JSFiddle - React, Tailwind, and code Playground

by lemon kazi

JavaScript

function isASCII(str) {
    return /^[\x00-\x7F]*$/.test(str);
	}
	console.log(lengthInUtf8Bytes('a指定し'));
	
	
	function lengthInUtf8Bytes(str) {
  // Matches only the 10.. bytes that are non-initial characters in a multi-byte sequence.
  var m = encodeURIComponent(str).match(/%[89ABab]/g);
  return str.length + (m ? m.length : 0);
}