src/libtsduck/base/tsUString.cpp
ts::ByteBlock ts::UString::toDVBWithByteLength(size_type start, size_type count, const DVBCharset* charset) const
{
    if (start >= length()) {
        // Empty string, return one byte containing 0 (the length).
        return ByteBlock(1, 0);
    }
    else {
        // The maximum number of DVB bytes is 255 so that the size fits in one byte.
        ByteBlock bb(256);

        // Convert the string.
        uint8_t* buffer = bb.data() + 1;
        size_type size = bb.size() - 1;
        toDVB(buffer, size, start, count, charset);

        // Truncate unused bytes.
        assert(size < bb.size());
        bb.resize(bb.size() - size);

        // Update length byte.
        bb[0] = uint8_t(bb.size() - 1);
        return bb;
    }
}
//----------------------------------------------------------------------------
// Encode this UTF-16 string into a DVB string (preceded by its one-byte length).
//----------------------------------------------------------------------------
Encode this UTF-16 string into a DVB string (preceded by its one-byte length).
Encode this UTF - 16 string into a DVB string ( preceded by its one - byte length ) .
ts::ByteBlock ts::UString::toDVBWithByteLength(size_type start, size_type count, const DVBCharset* charset) const
{
    if (start >= length()) {
        return ByteBlock(1, 0);
    }
    else {
        ByteBlock bb(256);
        uint8_t* buffer = bb.data() + 1;
        size_type size = bb.size() - 1;
        toDVB(buffer, size, start, count, charset);
        assert(size < bb.size());
        bb.resize(bb.size() - size);
        bb[0] = uint8_t(bb.size() - 1);
        return bb;
    }
}
ts :: ByteBlock ts :: UString :: toDVBWithByteLength ( size_type start , size_type count , const DVBCharset * charset ) const { if ( start >= length ( ) ) { return ByteBlock ( 1 , 0 ) ; } else { ByteBlock bb ( 256 ) ; uint8_t * buffer = bb . data ( ) + 1 ; size_type size = bb . size ( ) - 1 ; toDVB ( buffer , size , start , count , charset ) ; assert ( size < bb . size ( ) ) ; bb . resize ( bb . size ( ) - size ) ; bb [ 0 ] = uint8_t ( bb . size ( ) - 1 ) ; return bb ; } }
Encode this UTF-16 string into a DVB string (preceded by its one-byte length).
Encode this UTF - 16 string into a DVB string ( preceded by its one - byte length ) .
// Empty string, return one byte containing 0 (the length). // The maximum number of DVB bytes is 255 so that the size fits in one byte. // Convert the string. // Truncate unused bytes. // Update length byte.