TSDuck v3.40-4025
MPEG Transport Stream Toolkit
|
Definition of a character set for PSI/SI encoding. More...
#include <tsCharset.h>
Classes | |
class | DuplicateCharset |
Exception thrown when registering duplicate charsets. More... | |
class | InvalidCharset |
Exception thrown when registering invalid charsets. More... | |
Public Member Functions | |
virtual | ~Charset () |
Virtual destructor. | |
virtual bool | canEncode (const UString &str, size_t start=0, size_t count=NPOS) const =0 |
Check if a string can be encoded using the charset (ie all characters can be represented). | |
virtual bool | decode (UString &str, const uint8_t *data, size_t size) const =0 |
Decode a string from the specified byte buffer. | |
UString | decoded (const uint8_t *data, size_t size) const |
Decode a string from the specified byte buffer and return a UString. | |
UString | decodedWithByteLength (const uint8_t *&data, size_t &size) const |
Decode a string (preceded by its one-byte length) from the specified byte buffer. | |
bool | 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. | |
virtual size_t | encode (uint8_t *&buffer, size_t &size, const UString &str, size_t start=0, size_t count=NPOS) const =0 |
Encode a C++ Unicode string. | |
ByteBlock | encoded (const UString &str, size_t start=0, size_t count=NPOS) const |
Encode a C++ Unicode string as a ByteBlock. | |
ByteBlock | 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). | |
size_t | 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. | |
UString | name () const |
Get the character set name. | |
virtual void | unregister () const |
Unregister the character set from the repository of character sets. | |
Static Public Member Functions | |
static UStringList | GetAllNames () |
Find all registered character set names. | |
static const Charset * | GetCharset (const UString &name) |
Get a character set by name. | |
Protected Member Functions | |
Charset (const UChar *name=nullptr) | |
Protected constructor, registering the character set under one name. | |
Charset (std::initializer_list< const UChar * > names) | |
Protected constructor, registering the character set under any number of names. | |
Definition of a character set for PSI/SI encoding.
|
explicitprotected |
Protected constructor, registering the character set under one name.
[in] | name | Character set name. |
|
explicitprotected |
Protected constructor, registering the character set under any number of names.
[in] | names | Character set names. The first one is the "main" name. |
|
inline |
Get the character set name.
Get a character set by name.
[in] | name | Name of the requested character set. |
|
static |
Find all registered character set names.
|
pure virtual |
Decode a string from the specified byte buffer.
[out] | str | Returned decoded string. |
[in] | data | Address of an encoded string. |
[in] | size | Size in bytes of the encoded string. |
Implemented in ts::ARIBCharset, ts::DumpCharset, ts::DVBCharset, ts::DVBCharTableSingleByte, ts::DVBCharTableUTF16, and ts::DVBCharTableUTF8.
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.
[in] | data | Address of an encoded string. |
[in] | size | Size in bytes of the encoded string. |
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.
[out] | str | Returned decoded string. |
[in,out] | data | Address of an encoded string. The address is updated to point after the decoded value. |
[in,out] | size | Size of the buffer. Updated to remaining size. |
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.
[in,out] | data | Address of an encoded string. The address is updated to point after the decoded value. |
[in,out] | size | Size of the buffer. Updated to remaining size. |
|
pure virtual |
Check if a string can be encoded using the charset (ie all characters can be represented).
[in] | str | The string to encode. |
[in] | start | Starting offset in str. |
[in] | count | Maximum number of characters to encode. |
Implemented in ts::ARIBCharset, ts::DumpCharset, ts::DVBCharset, ts::DVBCharTableSingleByte, ts::DVBCharTableUTF16, and ts::DVBCharTableUTF8.
|
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.
[in,out] | buffer | Address of the buffer. The address is updated to point after the encoded value. |
[in,out] | size | Size of the buffer. Updated to remaining size. |
[in] | str | The string to encode. |
[in] | start | Starting offset in str. |
[in] | count | Maximum number of characters to encode. |
Implemented in ts::ARIBCharset, ts::DumpCharset, ts::DVBCharset, ts::DVBCharTableSingleByte, ts::DVBCharTableUTF16, and ts::DVBCharTableUTF8.
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.
[in,out] | buffer | Address of the buffer. The address is updated to point after the encoded value. |
[in,out] | size | Size of the buffer. Updated to remaining size. |
[in] | str | The string to encode. |
[in] | start | Starting offset in str. |
[in] | count | Maximum number of characters to encode. |
|
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.