TSDuck Version 3.15-964 (TSDuck - The MPEG Transport Stream Toolkit)
ts::DVBCharset Class Referenceabstract

Definition of a character set for DVB encoding. More...

Inheritance diagram for ts::DVBCharset:

Classes

class  DuplicateDVBCharset
 Exception thrown when registering duplicate charsets. More...
 
class  InvalidDVBCharset
 Exception thrown when registering invalid charsets. More...
 

Public Member Functions

virtual ~DVBCharset ()
 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). More...
 
virtual bool decode (UString &str, const uint8_t *dvb, size_t dvbSize) const =0
 Decode a DVB string from the specified byte buffer. More...
 
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 into a DVB string. More...
 
virtual size_t encodeTableCode (uint8_t *&buffer, size_t &size) const
 Encode the character set table code. More...
 
UString name () const
 Get the character set name. More...
 
uint32_t tableCode () const
 Get the DVB table code for the character set. More...
 

Static Public Member Functions

static UStringList GetAllNames ()
 Find all registered character set names. More...
 
static bool GetCharCodeTable (uint32_t &code, size_t &codeSize, const uint8_t *dvb, size_t dvbSize)
 This static function gets the character coding table at the beginning of a DVB string. More...
 
static DVBCharsetGetCharset (const UString &name)
 Get a DVB character set by name. More...
 
static DVBCharsetGetCharset (uint32_t tableCode)
 Get a DVB character set by table code. More...
 

Static Public Attributes

static const uint16_t DVB_CODEPOINT_CRLF = 0xE08A
 Code point for DVB-encoded CR/LF in two-byte character sets.
 
static const uint8_t DVB_SINGLE_BYTE_CRLF = 0x8A
 DVB-encoded CR/LF in single-byte character sets.
 

Protected Member Functions

 DVBCharset (const UString &name, uint32_t tableCode)
 Protected constructor. More...
 

Static Protected Member Functions

static void Unregister (const DVBCharset *charset)
 Remove the specified charset. More...
 

Detailed Description

Definition of a character set for DVB encoding.

See also
ETSI EN 300 468, Annex A.

Constructor & Destructor Documentation

◆ DVBCharset()

ts::DVBCharset::DVBCharset ( const UString name,
uint32_t  tableCode 
)
protected

Protected constructor.

Parameters
[in]namecharset name
[in]tableCodeDVB table code

Member Function Documentation

◆ GetCharCodeTable()

static bool ts::DVBCharset::GetCharCodeTable ( uint32_t &  code,
size_t &  codeSize,
const uint8_t *  dvb,
size_t  dvbSize 
)
static

This static function gets the character coding table at the beginning of a DVB string.

The character coding table is encoded on up to 3 bytes at the beginning of a DVB string. The following encodings are recognized, based on the first byte of the DVB string:

  • First byte >= 0x20: The first byte is a character. The default encoding is ISO-6937. We return zero as code.
  • First byte == 0x10: The next two bytes indicate an ISO-8859 encoding. We return 0x10xxyy as code.
  • First byte == 0x1F: The second byte is an encoding_type_id. This encoding is not supported here.
  • Other value: One byte encoding.
Parameters
[out]codeReturned character coding table value.
[out]codeSizeSize in bytes of character coding table in dvb.
[in]dvbAddress of a DVB string.
[in]dvbSizeSize in bytes of the DVB string.
Returns
True on success, false on error (truncated, unsupported format, etc.)

◆ name()

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

Get the character set name.

Returns
The name.

◆ tableCode()

uint32_t ts::DVBCharset::tableCode ( ) const
inline

Get the DVB table code for the character set.

Returns
DVB table code.

◆ GetCharset() [1/2]

static DVBCharset* ts::DVBCharset::GetCharset ( const UString name)
static

Get a DVB character set by name.

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

◆ GetCharset() [2/2]

static DVBCharset* ts::DVBCharset::GetCharset ( uint32_t  tableCode)
static

Get a DVB character set by table code.

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

◆ GetAllNames()

static UStringList ts::DVBCharset::GetAllNames ( )
static

Find all registered character set names.

Returns
List of all registered names.

◆ decode()

virtual bool ts::DVBCharset::decode ( UString str,
const uint8_t *  dvb,
size_t  dvbSize 
) const
pure virtual

Decode a DVB string from the specified byte buffer.

Parameters
[out]strReturned decoded string.
[in]dvbAddress of a DVB string.
[in]dvbSizeSize in bytes of the DVB string.
Returns
True on success, false on error (truncated, unsupported format, etc.)

Implemented in ts::DVBCharsetSingleByte, ts::DVBCharsetUTF16, and ts::DVBCharsetUTF8.

◆ canEncode()

virtual bool ts::DVBCharset::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::DVBCharsetSingleByte, ts::DVBCharsetUTF16, and ts::DVBCharsetUTF8.

◆ encodeTableCode()

virtual size_t ts::DVBCharset::encodeTableCode ( uint8_t *&  buffer,
size_t &  size 
) const
virtual

Encode the character set table code.

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.
Returns
The number of serialized byte.

◆ encode()

virtual size_t ts::DVBCharset::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 into a DVB string.

Unmappable 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::DVBCharsetSingleByte, ts::DVBCharsetUTF16, and ts::DVBCharsetUTF8.

◆ Unregister()

static void ts::DVBCharset::Unregister ( const DVBCharset charset)
staticprotected

Remove the specified charset.

Parameters
[in]charsetThe charset to remove.

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