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

#include <CharsetDetection.h>

Static Public Member Functions

static std::string GetBomEncoding (const char *const content, const size_t contentLength)
 
static std::string GetBomEncoding (const std::string &content)
 
static bool DetectXmlEncoding (const std::string &xmlContent, std::string &detectedEncoding)
 
static bool DetectXmlEncoding (const char *const xmlContent, const size_t contentLength, std::string &detectedEncoding)
 
static bool ConvertHtmlToUtf8 (const std::string &htmlContent, std::string &converted, const std::string &serverReportedCharset="")
 
static bool ConvertHtmlToUtf8 (const std::string &htmlContent, std::string &converted, const std::string &serverReportedCharset, std::string &usedHtmlCharset)
 
static bool ConvertPlainTextToUtf8 (const std::string &textContent, std::string &converted, const std::string &serverReportedCharset, std::string &usedCharset)
 

Member Function Documentation

◆ ConvertHtmlToUtf8() [1/2]

bool CCharsetDetection::ConvertHtmlToUtf8 ( const std::string & htmlContent,
std::string & converted,
const std::string & serverReportedCharset,
std::string & usedHtmlCharset )
static

Detect HTML charset and HTML convert to UTF-8

Parameters
htmlContentcontent of HTML file
convertedreceive result of conversion
serverReportedCharsetcharset from HTTP header or from other out-of-band source, empty if unknown or unset
usedHtmlCharsetreceive charset used for conversion
Returns
true if charset is properly detected and HTML is correctly converted, false if charset is only guessed

◆ ConvertHtmlToUtf8() [2/2]

static bool CCharsetDetection::ConvertHtmlToUtf8 ( const std::string & htmlContent,
std::string & converted,
const std::string & serverReportedCharset = "" )
inlinestatic

Detect HTML charset and HTML convert to UTF-8

Parameters
htmlContentcontent of HTML file
convertedreceive result of conversion
serverReportedCharsetcharset from HTTP header or from other out-of-band source, empty if unknown or unset
Returns
true if charset is properly detected and HTML is correctly converted, false if charset is only guessed

◆ ConvertPlainTextToUtf8()

bool CCharsetDetection::ConvertPlainTextToUtf8 ( const std::string & textContent,
std::string & converted,
const std::string & serverReportedCharset,
std::string & usedCharset )
static

Try to convert plain text to UTF-8 using best suitable charset

Parameters
textContenttext to convert
convertedreceive result of conversion
serverReportedCharsetcharset from HTTP header or from other out-of-band source, empty if unknown or unset
usedCharsetreceive charset used for conversion
Returns
true if converted without errors, false otherwise

◆ DetectXmlEncoding() [1/2]

bool CCharsetDetection::DetectXmlEncoding ( const char *const xmlContent,
const size_t contentLength,
std::string & detectedEncoding )
static

◆ DetectXmlEncoding() [2/2]

static bool CCharsetDetection::DetectXmlEncoding ( const std::string & xmlContent,
std::string & detectedEncoding )
inlinestatic

◆ GetBomEncoding() [1/2]

std::string CCharsetDetection::GetBomEncoding ( const char *const content,
const size_t contentLength )
static

Detect text encoding by Byte Order Mark Multibyte encodings (UTF-16/32) always ends with explicit endianness (LE/BE)

Parameters
contentpointer to text to analyze
contentLengthlength of text
Returns
detected encoding or empty string if BOM not detected

◆ GetBomEncoding() [2/2]

static std::string CCharsetDetection::GetBomEncoding ( const std::string & content)
inlinestatic

Detect text encoding by Byte Order Mark Multibyte encodings (UTF-16/32) always ends with explicit endianness (LE/BE)

Parameters
contentthe text to analyze
Returns
detected encoding or empty string if BOM not detected

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