|
libcrn
3.9.5
A document image processing library
|
Character set converter. More...
#include <CRNCharsetConverter.h>
Classes | |
| class | Exception |
| class | ExceptionIncompleteCode |
| class | ExceptionInvalidCharacter |
Public Types | |
| enum | Status { Status::OK, Status::BUFFER, Status::INVALID, Status::INCOMPLETE } |
Public Member Functions | |
| CharsetConverter (const std::string &to_code, bool translit=true, bool throw_exceptions=true) | |
| Constructor. More... | |
| CharsetConverter (const CharsetConverter &)=delete | |
| CharsetConverter (CharsetConverter &&)=delete | |
| CharsetConverter & | operator= (const CharsetConverter &)=delete |
| CharsetConverter & | operator= (CharsetConverter &&)=delete |
| ~CharsetConverter () | |
| Destructor. More... | |
| void | Reset (const std::string &to_code, bool translit=true) |
| Changes the charset to convert. More... | |
| std::string | FromUTF8 (const crn::StringUTF8 &str, Status *stat=nullptr) const |
| Converts from unicode to the selected charset. More... | |
| crn::StringUTF8 | ToUTF8 (const std::string &str, Status *stat=nullptr) const |
| Converts to unicode. More... | |
| const std::string & | GetCharset () const |
| Returns the used charset. More... | |
Character set converter.
A class to convert from any character set to UTF-8 and vice versa
Definition at line 41 of file CRNCharsetConverter.h.
|
strong |
| Enumerator | |
|---|---|
| OK | |
| BUFFER | |
| INVALID | |
| INCOMPLETE | |
Definition at line 44 of file CRNCharsetConverter.h.
| CharsetConverter::CharsetConverter | ( | const std::string & | to_code, |
| bool | translit = true, |
||
| bool | throw_exceptions = true |
||
| ) |
Constructor.
Constructor
| crn::ExceptionInvalidArgument | unsupported charset |
| [in] | to_code | the character set to convert |
| [in] | translit | shall incompatible characters be transliterated (default: yes) |
| [in] | throw_exceptions | shall the converter throw exceptions when an error occurred |
Definition at line 35 of file CRNCharsetConverter.cpp.
|
delete |
|
delete |
| CharsetConverter::~CharsetConverter | ( | ) |
| std::string CharsetConverter::FromUTF8 | ( | const crn::StringUTF8 & | str, |
| Status * | stat = nullptr |
||
| ) | const |
Converts from unicode to the selected charset.
Converts from unicode to the selected charset
| ExceptionInvalidCharacter | invalid character |
| ExceptionIncompleteCode | incomplete multibyte character |
| [in] | str | the UTF-8 string to convert |
| [in] | stat | a status variable (may be nullptr): if no error occurred, the status is left unchanged |
Definition at line 102 of file CRNCharsetConverter.cpp.
|
inline |
Returns the used charset.
Definition at line 96 of file CRNCharsetConverter.h.
|
delete |
|
delete |
| void CharsetConverter::Reset | ( | const std::string & | to_code, |
| bool | translit = true |
||
| ) |
Changes the charset to convert.
Changes the charset to convert
| crn::ExceptionInvalidArgument | unsupported charset |
| [in] | to_code | the character set to convert |
| [in] | translit | shall incompatible characters be transliterated (default: yes) |
Definition at line 57 of file CRNCharsetConverter.cpp.
| StringUTF8 CharsetConverter::ToUTF8 | ( | const std::string & | str, |
| Status * | stat = nullptr |
||
| ) | const |
Converts to unicode.
Converts to unicode
| ExceptionInvalidCharacter | invalid character |
| ExceptionIncompleteCode | incomplete multibyte character |
| [in] | str | the string to convert |
| [in] | stat | a status variable (may be nullptr): if no error occurred, the status is left unchanged |
Definition at line 167 of file CRNCharsetConverter.cpp.
1.8.6