The XMLTextEncoding class.
More...
#include <XMLTextEncoding.h>
|
| 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.
|
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.
◆ 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
-
| source | String to be converted. |
| result | Result of conversion (emty in case of any errors). |
| source_code_page | Code page of source string (if empty, default system encoding is used). |
| result_code_page | Desired 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
-
| document | String, 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
-
| str | String text encoding to be detected in. |
| filter | If 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).