public function read($len = null)
    {
        if (!$this->getInitialized()) {
            $this->initialize();
            $this->setInitialized(true);
        }

        // Process whole text at once.
        $text = null;
        while (($data = $this->in->read($len)) !== -1) {
            $text .= $data;
        }

        // At the end.
        if (null === $text) {
            return -1;
        }

        $textArray = preg_split("~\R~", $text);

        $lines = [];
        foreach ($textArray as $offset => $line) {
            $lines[] = trim(json_encode($line), '"');
            if (strlen($line) !== strlen($lines[$offset])) {
                $this->log(
                    "Escape unicode chars on line " . ($offset + 1)
                    . " from " . $line . " to " . $lines[$offset],
                    Project::MSG_VERBOSE
                );
            }
        }

        $escaped = implode(PHP_EOL, $lines);

        return $escaped;
    }