protected function calcByteLength($str) { $bytes = str_replace("\n", "", $str); return strlen($bytes); }