Kodi Documentation 22.0
Kodi is an open source media player and entertainment hub.
Loading...
Searching...
No Matches
CCharsetConverter Class Reference

#include <CharsetConverter.h>

Inheritance diagram for CCharsetConverter:
ISettingCallback

Classes

class  CInnerConverter
 

Public Member Functions

 CCharsetConverter ()
 
void OnSettingChanged (const std::shared_ptr< const CSetting > &setting) override
 The value of the given setting has changed.
 
- Public Member Functions inherited from ISettingCallback
virtual ~ISettingCallback ()=default
 
virtual bool OnSettingChanging (const std::shared_ptr< const CSetting > &setting)
 The value of the given setting is being changed.
 
virtual void OnSettingAction (const std::shared_ptr< const CSetting > &setting)
 The given setting has been activated.
 
virtual bool OnSettingUpdate (const std::shared_ptr< CSetting > &setting, const char *oldSettingId, const TiXmlNode *oldSettingNode)
 The given setting needs to be updated.
 
virtual void OnSettingPropertyChanged (const std::shared_ptr< const CSetting > &setting, const char *propertyName)
 The given property of the given setting has changed.
 

Static Public Member Functions

static void reset ()
 
static void resetSystemCharset ()
 
static void reinitCharsetsFromSettings (void)
 
static void clear ()
 
static bool utf8ToUtf32 (const std::string &utf8StringSrc, std::u32string &utf32StringDst, bool failOnBadChar=true)
 
static std::u32string utf8ToUtf32 (const std::string &utf8StringSrc, bool failOnBadChar=true)
 
static bool utf8ToUtf32Visual (const std::string &utf8StringSrc, std::u32string &utf32StringDst, bool bVisualBiDiFlip=false, bool forceLTRReadingOrder=false, bool failOnBadChar=false)
 
static bool utf32ToUtf8 (const std::u32string &utf32StringSrc, std::string &utf8StringDst, bool failOnBadChar=false)
 
static std::string utf32ToUtf8 (const std::u32string &utf32StringSrc, bool failOnBadChar=false)
 
static bool utf32ToW (const std::u32string &utf32StringSrc, std::wstring &wStringDst, bool failOnBadChar=false)
 
static bool utf32logicalToVisualBiDi (const std::u32string &logicalStringSrc, std::u32string &visualStringDst, bool forceLTRReadingOrder=false, bool failOnBadString=false, int *visualToLogicalMap=nullptr)
 
static bool wToUtf32 (const std::wstring &wStringSrc, std::u32string &utf32StringDst, bool failOnBadChar=false)
 
static bool utf8ToW (const std::string &utf8StringSrc, std::wstring &wStringDst, bool bVisualBiDiFlip=true, bool forceLTRReadingOrder=false, bool failOnBadChar=false)
 
static bool utf16LEtoW (const std::u16string &utf16String, std::wstring &wString)
 
static bool subtitleCharsetToUtf8 (const std::string &stringSrc, std::string &utf8StringDst)
 
static bool utf8ToStringCharset (const std::string &utf8StringSrc, std::string &stringDst)
 
static bool utf8ToStringCharset (std::string &stringSrcDst)
 
static bool utf8ToSystem (std::string &stringSrcDst, bool failOnBadChar=false)
 
static bool systemToUtf8 (const std::string &sysStringSrc, std::string &utf8StringDst, bool failOnBadChar=false)
 
static bool utf8To (const std::string &strDestCharset, const std::string &utf8StringSrc, std::string &stringDst)
 
static bool utf8To (const std::string &strDestCharset, const std::string &utf8StringSrc, std::u16string &utf16StringDst)
 
static bool utf8To (const std::string &strDestCharset, const std::string &utf8StringSrc, std::u32string &utf32StringDst)
 
static bool ToUtf8 (const std::string &strSourceCharset, const std::string &stringSrc, std::string &utf8StringDst, bool failOnBadChar=false)
 
static bool wToUTF8 (const std::wstring &wStringSrc, std::string &utf8StringDst, bool failOnBadChar=false)
 
static bool utf16BEtoUTF8 (const std::u16string &utf16StringSrc, std::string &utf8StringDst)
 Convert UTF-16BE (u16string) string to UTF-8 string. No RTL visual-logical transformation is performed.
 
static bool utf16BEtoUTF8 (const std::string &utf16StringSrc, std::string &utf8StringDst)
 Convert UTF-16BE (string) string to UTF-8 string. No RTL visual-logical transformation is performed.
 
static bool utf16LEtoUTF8 (const std::u16string &utf16StringSrc, std::string &utf8StringDst)
 
static bool ucs2ToUTF8 (const std::u16string &ucs2StringSrc, std::string &utf8StringDst)
 
static bool MacintoshToUTF8 (const std::string &macStringSrc, std::string &utf8StringDst)
 Convert Macintosh (string) string to UTF-8 string. No RTL visual-logical transformation is performed.
 
static bool utf8logicalToVisualBiDi (const std::string &utf8StringSrc, std::string &utf8StringDst, bool failOnBadString=false)
 
static bool utf8IsRTLBidiDirection (const std::string &utf8String)
 
static bool utf32ToStringCharset (const std::u32string &utf32StringSrc, std::string &stringDst)
 
static std::vector< std::string > getCharsetLabels ()
 
static std::string getCharsetLabelByName (const std::string &charsetName)
 
static std::string getCharsetNameByLabel (const std::string &charsetLabel)
 
static bool unknownToUTF8 (std::string &stringSrcDst)
 
static bool unknownToUTF8 (const std::string &stringSrc, std::string &utf8StringDst, bool failOnBadChar=false)
 
static bool toW (const std::string &stringSrc, std::wstring &wStringDst, const std::string &enc)
 
static bool fromW (const std::wstring &wStringSrc, std::string &stringDst, const std::string &enc)
 
static void SettingOptionsCharsetsFiller (const std::shared_ptr< const CSetting > &setting, std::vector< StringSettingOption > &list, std::string &current, void *data)
 

Constructor & Destructor Documentation

◆ CCharsetConverter()

CCharsetConverter::CCharsetConverter ( )
default

Member Function Documentation

◆ clear()

void CCharsetConverter::clear ( )
static

◆ fromW()

bool CCharsetConverter::fromW ( const std::wstring & wStringSrc,
std::string & stringDst,
const std::string & enc )
static

◆ getCharsetLabelByName()

std::string CCharsetConverter::getCharsetLabelByName ( const std::string & charsetName)
static

◆ getCharsetLabels()

std::vector< std::string > CCharsetConverter::getCharsetLabels ( )
static

◆ getCharsetNameByLabel()

std::string CCharsetConverter::getCharsetNameByLabel ( const std::string & charsetLabel)
static

◆ MacintoshToUTF8()

bool CCharsetConverter::MacintoshToUTF8 ( const std::string & macStringSrc,
std::string & utf8StringDst )
static

Convert Macintosh (string) string to UTF-8 string. No RTL visual-logical transformation is performed.

Parameters
macStringSrcIs source Macintosh string to convert
utf8StringDstIs output UTF-8 string, empty on any error
Returns
True on successful conversion, false on any error

◆ OnSettingChanged()

void CCharsetConverter::OnSettingChanged ( const std::shared_ptr< const CSetting > & setting)
overridevirtual

The value of the given setting has changed.

This callback is triggered whenever the value of a setting has been successfully changed (i.e. none of the OnSettingChanging() handlers) has reverted the change.

Parameters
settingThe setting whose value has been changed

Reimplemented from ISettingCallback.

◆ reinitCharsetsFromSettings()

void CCharsetConverter::reinitCharsetsFromSettings ( void )
static

◆ reset()

void CCharsetConverter::reset ( void )
static

◆ resetSystemCharset()

void CCharsetConverter::resetSystemCharset ( void )
static

◆ SettingOptionsCharsetsFiller()

void CCharsetConverter::SettingOptionsCharsetsFiller ( const std::shared_ptr< const CSetting > & setting,
std::vector< StringSettingOption > & list,
std::string & current,
void * data )
static

◆ subtitleCharsetToUtf8()

bool CCharsetConverter::subtitleCharsetToUtf8 ( const std::string & stringSrc,
std::string & utf8StringDst )
static

◆ systemToUtf8()

bool CCharsetConverter::systemToUtf8 ( const std::string & sysStringSrc,
std::string & utf8StringDst,
bool failOnBadChar = false )
static

◆ ToUtf8()

bool CCharsetConverter::ToUtf8 ( const std::string & strSourceCharset,
const std::string & stringSrc,
std::string & utf8StringDst,
bool failOnBadChar = false )
static

◆ toW()

bool CCharsetConverter::toW ( const std::string & stringSrc,
std::wstring & wStringDst,
const std::string & enc )
static

◆ ucs2ToUTF8()

bool CCharsetConverter::ucs2ToUTF8 ( const std::u16string & ucs2StringSrc,
std::string & utf8StringDst )
static

◆ unknownToUTF8() [1/2]

bool CCharsetConverter::unknownToUTF8 ( const std::string & stringSrc,
std::string & utf8StringDst,
bool failOnBadChar = false )
static

◆ unknownToUTF8() [2/2]

bool CCharsetConverter::unknownToUTF8 ( std::string & stringSrcDst)
static

◆ utf16BEtoUTF8() [1/2]

bool CCharsetConverter::utf16BEtoUTF8 ( const std::string & utf16StringSrc,
std::string & utf8StringDst )
static

Convert UTF-16BE (string) string to UTF-8 string. No RTL visual-logical transformation is performed.

Parameters
utf16StringSrcIs source UTF-16BE string to convert
utf8StringDstIs output UTF-8 string, empty on any error
Returns
True on successful conversion, false on any error

◆ utf16BEtoUTF8() [2/2]

bool CCharsetConverter::utf16BEtoUTF8 ( const std::u16string & utf16StringSrc,
std::string & utf8StringDst )
static

Convert UTF-16BE (u16string) string to UTF-8 string. No RTL visual-logical transformation is performed.

Parameters
utf16StringSrcIs source UTF-16BE u16string string to convert
utf8StringDstIs output UTF-8 string, empty on any error
Returns
True on successful conversion, false on any error

◆ utf16LEtoUTF8()

bool CCharsetConverter::utf16LEtoUTF8 ( const std::u16string & utf16StringSrc,
std::string & utf8StringDst )
static

◆ utf16LEtoW()

bool CCharsetConverter::utf16LEtoW ( const std::u16string & utf16String,
std::wstring & wString )
static

◆ utf32logicalToVisualBiDi()

bool CCharsetConverter::utf32logicalToVisualBiDi ( const std::u32string & logicalStringSrc,
std::u32string & visualStringDst,
bool forceLTRReadingOrder = false,
bool failOnBadString = false,
int * visualToLogicalMap = nullptr )
static

Perform logical to visual flip.

Parameters
logicalStringSrcis source string with logical characters order
visualStringDstis output string with visual characters order, empty on any error
forceLTRReadingOrderforce LTR reading order
visualToLogicalMapis output mapping of positions in the visual string to the logical string
Returns
true on success, false otherwise

◆ utf32ToStringCharset()

bool CCharsetConverter::utf32ToStringCharset ( const std::u32string & utf32StringSrc,
std::string & stringDst )
static

◆ utf32ToUtf8() [1/2]

std::string CCharsetConverter::utf32ToUtf8 ( const std::u32string & utf32StringSrc,
bool failOnBadChar = false )
static

Convert UTF-32 string to UTF-8 string. No RTL visual-logical transformation is performed.

Parameters
utf32StringSrcis source UTF-32 string to convert
failOnBadCharif set to true function will fail on invalid character, otherwise invalid character will be skipped
Returns
converted string on successful conversion, empty string on any error

◆ utf32ToUtf8() [2/2]

bool CCharsetConverter::utf32ToUtf8 ( const std::u32string & utf32StringSrc,
std::string & utf8StringDst,
bool failOnBadChar = false )
static

Convert UTF-32 string to UTF-8 string. No RTL visual-logical transformation is performed.

Parameters
utf32StringSrcis source UTF-32 string to convert
utf8StringDstis output UTF-8 string, empty on any error
failOnBadCharif set to true function will fail on invalid character, otherwise invalid character will be skipped
Returns
true on successful conversion, false on any error

◆ utf32ToW()

bool CCharsetConverter::utf32ToW ( const std::u32string & utf32StringSrc,
std::wstring & wStringDst,
bool failOnBadChar = false )
static

Convert UTF-32 string to wchar_t string (wstring). No RTL visual-logical transformation is performed.

Parameters
utf32StringSrcis source UTF-32 string to convert
wStringDstis output wchar_t string, empty on any error
failOnBadCharif set to true function will fail on invalid character, otherwise invalid character will be skipped
Returns
true on successful conversion, false on any error

◆ utf8IsRTLBidiDirection()

bool CCharsetConverter::utf8IsRTLBidiDirection ( const std::string & utf8String)
static

Check if a string has RTL direction.

Parameters
utf8StringSrcthe string
Returns
true if the string is RTL, otherwise false

◆ utf8logicalToVisualBiDi()

bool CCharsetConverter::utf8logicalToVisualBiDi ( const std::string & utf8StringSrc,
std::string & utf8StringDst,
bool failOnBadString = false )
static

◆ utf8To() [1/3]

bool CCharsetConverter::utf8To ( const std::string & strDestCharset,
const std::string & utf8StringSrc,
std::string & stringDst )
static

◆ utf8To() [2/3]

bool CCharsetConverter::utf8To ( const std::string & strDestCharset,
const std::string & utf8StringSrc,
std::u16string & utf16StringDst )
static

◆ utf8To() [3/3]

bool CCharsetConverter::utf8To ( const std::string & strDestCharset,
const std::string & utf8StringSrc,
std::u32string & utf32StringDst )
static

◆ utf8ToStringCharset() [1/2]

bool CCharsetConverter::utf8ToStringCharset ( const std::string & utf8StringSrc,
std::string & stringDst )
static

◆ utf8ToStringCharset() [2/2]

bool CCharsetConverter::utf8ToStringCharset ( std::string & stringSrcDst)
static

◆ utf8ToSystem()

bool CCharsetConverter::utf8ToSystem ( std::string & stringSrcDst,
bool failOnBadChar = false )
static

◆ utf8ToUtf32() [1/2]

std::u32string CCharsetConverter::utf8ToUtf32 ( const std::string & utf8StringSrc,
bool failOnBadChar = true )
static

Convert UTF-8 string to UTF-32 string. No RTL logical-visual transformation is performed.

Parameters
utf8StringSrcis source UTF-8 string to convert
failOnBadCharif set to true function will fail on invalid character, otherwise invalid character will be skipped
Returns
converted string on successful conversion, empty string on any error

◆ utf8ToUtf32() [2/2]

bool CCharsetConverter::utf8ToUtf32 ( const std::string & utf8StringSrc,
std::u32string & utf32StringDst,
bool failOnBadChar = true )
static

Convert UTF-8 string to UTF-32 string. No RTL logical-visual transformation is performed.

Parameters
utf8StringSrcis source UTF-8 string to convert
utf32StringDstis output UTF-32 string, empty on any error
failOnBadCharif set to true function will fail on invalid character, otherwise invalid character will be skipped
Returns
true on successful conversion, false on any error

◆ utf8ToUtf32Visual()

bool CCharsetConverter::utf8ToUtf32Visual ( const std::string & utf8StringSrc,
std::u32string & utf32StringDst,
bool bVisualBiDiFlip = false,
bool forceLTRReadingOrder = false,
bool failOnBadChar = false )
static

Convert UTF-8 string to UTF-32 string. RTL logical-visual transformation is optionally performed. Use it for readable text, GUI strings etc.

Parameters
utf8StringSrcis source UTF-8 string to convert
utf32StringDstis output UTF-32 string, empty on any error
bVisualBiDiFlipallow RTL visual-logical transformation if set to true, must be set to false is logical-visual transformation is already done
forceLTRReadingOrderforce LTR reading order
failOnBadCharif set to true function will fail on invalid character, otherwise invalid character will be skipped
Returns
true on successful conversion, false on any error

◆ utf8ToW()

bool CCharsetConverter::utf8ToW ( const std::string & utf8StringSrc,
std::wstring & wStringDst,
bool bVisualBiDiFlip = true,
bool forceLTRReadingOrder = false,
bool failOnBadChar = false )
static

◆ wToUtf32()

bool CCharsetConverter::wToUtf32 ( const std::wstring & wStringSrc,
std::u32string & utf32StringDst,
bool failOnBadChar = false )
static

Strictly convert wchar_t string (wstring) to UTF-32 string. No RTL visual-logical transformation is performed.

Parameters
wStringSrcis source wchar_t string to convert
utf32StringDstis output UTF-32 string, empty on any error
failOnBadCharif set to true function will fail on invalid character, otherwise invalid character will be skipped
Returns
true on successful conversion, false on any error

◆ wToUTF8()

bool CCharsetConverter::wToUTF8 ( const std::wstring & wStringSrc,
std::string & utf8StringDst,
bool failOnBadChar = false )
static

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