Vendor/phpspreadsheet/phpoffice/phpspreadsheet/src/PhpSpreadsheet/Shared/StringHelper.php
public static function UTF8toBIFF8UnicodeShort($value, $arrcRuns = [])
    {
        // character count
        $ln = self::countCharacters($value, 'UTF-8');
        // option flags
        if (empty($arrcRuns)) {
            $data = pack('CC', $ln, 0x0001);
            // characters
            $data .= self::convertEncoding($value, 'UTF-16LE', 'UTF-8');
        } else {
            $data = pack('vC', $ln, 0x09);
            $data .= pack('v', count($arrcRuns));
            // characters
            $data .= self::convertEncoding($value, 'UTF-16LE', 'UTF-8');
            foreach ($arrcRuns as $cRun) {
                $data .= pack('v', $cRun['strlen']);
                $data .= pack('v', $cRun['fontidx']);
            }
        }

        return $data;
    }
public static function UTF8toBIFF8UnicodeShort($value, $arrcRuns = [])
    {
        // character count
        $ln = self::countCharacters($value, 'UTF-8');
        // option flags
        if (empty($arrcRuns)) {
            $data = pack('CC', $ln, 0x0001);
            // characters
            $data .= self::convertEncoding($value, 'UTF-16LE', 'UTF-8');
        } else {
            $data = pack('vC', $ln, 0x09);
            $data .= pack('v', count($arrcRuns));
            // characters
            $data .= self::convertEncoding($value, 'UTF-16LE', 'UTF-8');
            foreach ($arrcRuns as $cRun) {
                $data .= pack('v', $cRun['strlen']);
                $data .= pack('v', $cRun['fontidx']);
            }
        }

        return $data;
    }
Converts a UTF-8 string into BIFF8 Unicode string data (8-bit string length)
Writes the string using uncompressed notation, no rich text, no Asian phonetics
If mbstring extension is not available, ASCII is assumed, and compressed notation is used
although this will give wrong results for non-ASCII strings
see OpenOffice.org's Documentation of the Microsoft Excel File Format, sect. 2.5.3.

@param string $value UTF-8 encoded string
@param mixed[] $arrcRuns Details of rich text runs in $value

@return string