XMLParserCPP 1.0
Loading...
Searching...
No Matches
XMLTextEncoding Class Reference

The XMLTextEncoding class. More...

#include <XMLTextEncoding.h>

Static Public Member Functions

static std::string detectDocumentEncoding (const std::string &document)
 Detects XML document encoding.
static std::vector< std::string > detectStringEncoding (const std::string &str, const bool &filter=bool(false))
 Detects text string encoding.
static void convertToEncoding (const std::string &source, std::string &result, const std::string &source_code_page, const std::string &result_code_page)
 Converts string from one encoding to another.

Detailed Description

The XMLTextEncoding class.

This class contains methods for text encodings processing. Some of these methods are suitable not only for XML documents, but also for any text strings.

Member Function Documentation

◆ convertToEncoding()

void XMLTextEncoding::convertToEncoding ( const std::string & source,
std::string & result,
const std::string & source_code_page,
const std::string & result_code_page )
static

Converts string from one encoding to another.

Parameters
sourceString to be converted.
resultResult of conversion (emty in case of any errors).
source_code_pageCode page of source string (if empty, default system encoding is used).
result_code_pageDesired code page of resylt string (if empty, resylt will use default system encoding).

◆ detectDocumentEncoding()

std::string XMLTextEncoding::detectDocumentEncoding ( const std::string & document)
static

Detects XML document encoding.

This method tries to detect encoding from the XML header. If operation was not successfull, tries to detect encoding by ICU library methods.

Parameters
documentString, containing XML document.
Returns
Text code page. Empty in case of any errors.

◆ detectStringEncoding()

std::vector< std::string > XMLTextEncoding::detectStringEncoding ( const std::string & str,
const bool & filter = bool(false) )
static

Detects text string encoding.

Parameters
strString text encoding to be detected in.
filterIf true, algorithm ignores html and xml tags.
Returns
Vector with all found encoding names. First element in vector is most suitable result (see ICU documentation for details).