private static function encodeString($string)
    {
        $length = mb_strlen($string, self::STRING_ENCODING);

        $data = self::encodeIntValue(MajorType::UTF8_STRING, $length);

        for ($i = 0; $i < $length; $i++)
        {
            $mbchar = mb_substr($string, $i, 1);
            $chars = strlen($mbchar);
            for ($j = 0; $j < $chars; $j++)
            {
                $data .= pack(PackFormat::UINT_8, ord($mbchar[$j]));
            }
        }

        return $data;
    }
private static function encodeString($string)
    {
        $length = mb_strlen($string, self::STRING_ENCODING);

        $data = self::encodeIntValue(MajorType::UTF8_STRING, $length);

        for ($i = 0; $i < $length; $i++)
        {
            $mbchar = mb_substr($string, $i, 1);
            $chars = strlen($mbchar);
            for ($j = 0; $j < $chars; $j++)
            {
                $data .= pack(PackFormat::UINT_8, ord($mbchar[$j]));
            }
        }

        return $data;
    }
private static function encodeString ( $ string ) { $ length = mb_strlen ( $ string , self :: STRING_ENCODING ) ; $ data = self :: encodeIntValue ( MajorType :: UTF8_STRING , $ length ) ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ mbchar = mb_substr ( $ string , $ i , 1 ) ; $ chars = strlen ( $ mbchar ) ; for ( $ j = 0 ; $ j < $ chars ; $ j ++ ) { $ data .= pack ( PackFormat :: UINT_8 , ord ( $ mbchar [ $ j ] ) ) ; } } return $ data ; }
Encodes a string.

@param string $string String to encode.
@return string The encoded byte string.
@throws CborException If the string is too long to be encoded in CBOR.
Encodes a string .