src/Diff.php
public function toDelta() {
        $diffs = $this->getChanges();

        $text = array();
        foreach ($diffs as $change) {
            $op = $change[0];
            $data = $change[1];

            if ($op == self::INSERT) {
                $text[] = '+'. Utils::escapeString($data);
            } elseif ($op == self::DELETE) {
                $text[] = '-' . mb_strlen($data);
            } else {
                $text[] = '=' . mb_strlen($data);
            }
        }

        return implode("\t", $text);
    }
public function toDelta() {
        $diffs = $this->getChanges();

        $text = array();
        foreach ($diffs as $change) {
            $op = $change[0];
            $data = $change[1];

            if ($op == self::INSERT) {
                $text[] = '+'. Utils::escapeString($data);
            } elseif ($op == self::DELETE) {
                $text[] = '-' . mb_strlen($data);
            } else {
                $text[] = '=' . mb_strlen($data);
            }
        }

        return implode("\t", $text);
    }
Crush the diff into an encoded string which describes the operations
required to transform text1 into text2.
E.g. =3\t-2\t+ing  -> Keep 3 chars, delete 2 chars, insert 'ing'.
Operations are tab-separated.  Inserted text is escaped using %xx notation.

@return string Delta text.