libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | List of all members
crn::CharsetConverter Class Reference

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
 
CharsetConverteroperator= (const CharsetConverter &)=delete
 
CharsetConverteroperator= (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...
 

Detailed Description

Character set converter.

A class to convert from any character set to UTF-8 and vice versa

Version
0.1
Author
Yann LEYDIER
Date
Apr 2012

Definition at line 41 of file CRNCharsetConverter.h.

Member Enumeration Documentation

Enumerator
OK 
BUFFER 
INVALID 
INCOMPLETE 

Definition at line 44 of file CRNCharsetConverter.h.

Constructor & Destructor Documentation

CharsetConverter::CharsetConverter ( const std::string &  to_code,
bool  translit = true,
bool  throw_exceptions = true 
)

Constructor.

Constructor

Exceptions
crn::ExceptionInvalidArgumentunsupported charset
Parameters
[in]to_codethe character set to convert
[in]translitshall incompatible characters be transliterated (default: yes)
[in]throw_exceptionsshall the converter throw exceptions when an error occurred

Definition at line 35 of file CRNCharsetConverter.cpp.

crn::CharsetConverter::CharsetConverter ( const CharsetConverter )
delete
crn::CharsetConverter::CharsetConverter ( CharsetConverter &&  )
delete
CharsetConverter::~CharsetConverter ( )

Destructor.

Destructor

Definition at line 43 of file CRNCharsetConverter.cpp.

Member Function Documentation

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

Exceptions
ExceptionInvalidCharacterinvalid character
ExceptionIncompleteCodeincomplete multibyte character
Parameters
[in]strthe UTF-8 string to convert
[in]stata status variable (may be nullptr): if no error occurred, the status is left unchanged
Returns
the converted string

Definition at line 102 of file CRNCharsetConverter.cpp.

const std::string& crn::CharsetConverter::GetCharset ( ) const
inline

Returns the used charset.

Definition at line 96 of file CRNCharsetConverter.h.

CharsetConverter& crn::CharsetConverter::operator= ( const CharsetConverter )
delete
CharsetConverter& crn::CharsetConverter::operator= ( CharsetConverter &&  )
delete
void CharsetConverter::Reset ( const std::string &  to_code,
bool  translit = true 
)

Changes the charset to convert.

Changes the charset to convert

Exceptions
crn::ExceptionInvalidArgumentunsupported charset
Parameters
[in]to_codethe character set to convert
[in]translitshall 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

Exceptions
ExceptionInvalidCharacterinvalid character
ExceptionIncompleteCodeincomplete multibyte character
Parameters
[in]strthe string to convert
[in]stata status variable (may be nullptr): if no error occurred, the status is left unchanged
Returns
the UTF-8 string

Definition at line 167 of file CRNCharsetConverter.cpp.


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