protected function cleanSource($content): string
    {
        if (is_null($this->path)) {
            throw \AWonderPHP\FileWrapper\NullPropertyException::propertyIsNull('path');
        }
        //nuke BOM when we definitely have UTF8
        $bom = pack('H*', 'EFBBBF');
        //DOS to UNIX
        $content = str_replace("\r\n", "\n", $content);
        //Classic Mac to UNIX
        $content = str_replace("\r", "\n", $content);
        if (function_exists('mb_detect_encoding')) {
            if (mb_detect_encoding($content, 'UTF-8', true)) {
                $this->charEnc="UTF-8";
                $content = preg_replace("/^$bom/", '', $content);
            } elseif ($ENC = mb_detect_encoding($content, $this->charsetlist, true)) {
                $this->charEnc=$ENC;
                if (function_exists('iconv')) {
                    if ($new = iconv($ENC, 'UTF-8', $content)) {
                        $this->charEnc="UTF-8";
                        $content = preg_replace("/^$bom/", '', $new);
                    } else {
                      //conversion failed
                        error_log('Could not convert ' . $this->path . ' to UTF-8');
                    }
                }
            } else {
              //we could not detect character encoding
                error_log('Could not identify character encoding for ' . $this->path);
            }
        }
        return($content);
    }