TSDuck v3.46-4964
MPEG Transport Stream Toolkit
Loading...
Searching...
No Matches
ts::Charset Class Referenceabstract

#include <tsCharset.h>

Inheritance diagram for ts::Charset:

Classes

class  InvalidCharset

Public Member Functions

virtual ~Charset ()
virtual bool canEncode (const UString &str, size_t start=0, size_t count=NPOS) const =0
virtual bool decode (UString &str, const uint8_t *data, size_t size) const =0
UString decoded (const uint8_t *data, size_t size) const
UString decodedWithByteLength (const uint8_t *&data, size_t &size) const
bool decodeWithByteLength (UString &str, const uint8_t *&data, size_t &size) const
virtual size_t encode (uint8_t *&buffer, size_t &size, const UString &str, size_t start=0, size_t count=NPOS) const =0
ByteBlock encoded (const UString &str, size_t start=0, size_t count=NPOS) const
ByteBlock encodedWithByteLength (const UString &str, size_t start=0, size_t count=NPOS) const
size_t encodeWithByteLength (uint8_t *&buffer, size_t &size, const UString &str, size_t start=0, size_t count=NPOS) const
UString name () const
virtual void unregister () const

Static Public Member Functions

static UStringList GetAllNames ()
static const Charset * GetCharset (const UString &name)

Protected Member Functions

 Charset (const UChar *name=nullptr)
 Charset (std::initializer_list< const UChar * > names)

Detailed Description

Definition of a character set for PSI/SI encoding.

Constructor & Destructor Documentation

◆ ~Charset()

virtual ts::Charset::~Charset ( )
virtual

Virtual destructor.

◆ Charset() [1/2]

ts::Charset::Charset ( const UChar * name = nullptr)
explicitprotected

Protected constructor, registering the character set under one name.

Parameters
[in]nameCharacter set name.

◆ Charset() [2/2]

ts::Charset::Charset ( std::initializer_list< const UChar * > names)
explicitprotected

Protected constructor, registering the character set under any number of names.

Parameters
[in]namesCharacter set names. The first one is the "main" name.

Member Function Documentation

◆ name()

UString ts::Charset::name ( ) const
inline

Get the character set name.

Returns
The name.

◆ GetCharset()

const Charset * ts::Charset::GetCharset ( const UString & name)
static

Get a character set by name.

Parameters
[in]nameName of the requested character set.
Returns
Address of the character set or zero if not found.

◆ GetAllNames()

UStringList ts::Charset::GetAllNames ( )
static

Find all registered character set names.

Returns
List of all registered names.

◆ decode()

virtual bool ts::Charset::decode ( UString & str,
const uint8_t * data,
size_t size ) const
pure virtual

Decode a string from the specified byte buffer.

Parameters
[out]strReturned decoded string.
[in]dataAddress of an encoded string.
[in]sizeSize in bytes of the encoded string.
Returns
True on success, false on error (truncated, unsupported format, etc.)

Implemented in ts::ARIBCharset, ts::DumpCharset, ts::DVBCharset, ts::DVBCharTableSingleByte, ts::DVBCharTableUTF16, and ts::DVBCharTableUTF8.

◆ decoded()

UString ts::Charset::decoded ( const uint8_t * data,
size_t size ) const

Decode a string from the specified byte buffer and return a UString.

Errors (truncation, unsupported format, etc) are ignored.

Parameters
[in]dataAddress of an encoded string.
[in]sizeSize in bytes of the encoded string.
Returns
The decoded string.

◆ decodeWithByteLength()

bool ts::Charset::decodeWithByteLength ( UString & str,
const uint8_t *& data,
size_t & size ) const

Decode a string (preceded by its one-byte length) from the specified byte buffer.

Parameters
[out]strReturned decoded string.
[in,out]dataAddress of an encoded string. The address is updated to point after the decoded value.
[in,out]sizeSize of the buffer. Updated to remaining size.
Returns
True on success, false on error (truncated, unsupported format, etc.)

◆ decodedWithByteLength()

UString ts::Charset::decodedWithByteLength ( const uint8_t *& data,
size_t & size ) const

Decode a string (preceded by its one-byte length) from the specified byte buffer.

Errors (truncation, unsupported format, etc) are ignored.

Parameters
[in,out]dataAddress of an encoded string. The address is updated to point after the decoded value.
[in,out]sizeSize of the buffer. Updated to remaining size.
Returns
The decoded string.

◆ canEncode()

virtual bool ts::Charset::canEncode ( const UString & str,
size_t start = 0,
size_t count = NPOS ) const
pure virtual

Check if a string can be encoded using the charset (ie all characters can be represented).

Parameters
[in]strThe string to encode.
[in]startStarting offset in str.
[in]countMaximum number of characters to encode.
Returns
True if all characters can be encoded.

Implemented in ts::ARIBCharset, ts::DumpCharset, ts::DVBCharset, ts::DVBCharTableSingleByte, ts::DVBCharTableUTF16, and ts::DVBCharTableUTF8.

◆ encode()

virtual size_t ts::Charset::encode ( uint8_t *& buffer,
size_t & size,
const UString & str,
size_t start = 0,
size_t count = NPOS ) const
pure virtual

Encode a C++ Unicode string.

Unrepresentable characters are skipped. Stop either when the specified number of characters are serialized or when the buffer is full, whichever comes first.

Parameters
[in,out]bufferAddress of the buffer. The address is updated to point after the encoded value.
[in,out]sizeSize of the buffer. Updated to remaining size.
[in]strThe string to encode.
[in]startStarting offset in str.
[in]countMaximum number of characters to encode.
Returns
The number of serialized characters (which is usually not the same as the number of written bytes).

Implemented in ts::ARIBCharset, ts::DumpCharset, ts::DVBCharset, ts::DVBCharTableSingleByte, ts::DVBCharTableUTF16, and ts::DVBCharTableUTF8.

◆ encodeWithByteLength()

size_t ts::Charset::encodeWithByteLength ( uint8_t *& buffer,
size_t & size,
const UString & str,
size_t start = 0,
size_t count = NPOS ) const

Encode a C++ Unicode string preceded by its one-byte length.

Unrepresentable characters are skipped. Stop either when the specified number of characters are serialized or when the buffer is full, whichever comes first.

Parameters
[in,out]bufferAddress of the buffer. The address is updated to point after the encoded value.
[in,out]sizeSize of the buffer. Updated to remaining size.
[in]strThe string to encode.
[in]startStarting offset in str.
[in]countMaximum number of characters to encode.
Returns
The number of serialized characters (which is usually not the same as the number of written bytes).

◆ encoded()

ByteBlock ts::Charset::encoded ( const UString & str,
size_t start = 0,
size_t count = NPOS ) const

Encode a C++ Unicode string as a ByteBlock.

Unrepresentable characters are skipped.

Parameters
[in]strThe string to encode.
[in]startStarting offset in str.
[in]countMaximum number of characters to encode.
Returns
A ByteBlock containing the encoded string.

◆ encodedWithByteLength()

ByteBlock ts::Charset::encodedWithByteLength ( const UString & str,
size_t start = 0,
size_t count = NPOS ) const

Encode a C++ Unicode string as a ByteBlock (preceded by its one-byte length).

Unrepresentable characters are skipped.

Parameters
[in]strThe string to encode.
[in]startStarting offset in str.
[in]countMaximum number of characters to encode.
Returns
A ByteBlock containing the encoded string.

◆ unregister()

virtual void ts::Charset::unregister ( ) const
virtual

Unregister the character set from the repository of character sets. This is done automatically when the object is destructed. Can be called earlier to make sure a character set is no longer referenced.

Reimplemented in ts::DVBCharTable.


The documentation for this class was generated from the following file: