Doxygen
Loading...
Searching...
No Matches
HtmlHelpRecoder Class Reference

Helper class to deal with recoding the UTF8 encoded text back to the native encoding specified by CHM_INDEX_ENCODING. More...

Public Member Functions

 HtmlHelpRecoder ()
 
 ~HtmlHelpRecoder ()
 
void initialize ()
 
void finalize ()
 
QCString recode (const QCString &s)
 

Private Attributes

void * m_iconv_null = reinterpret_cast<void*>(-1)
 
void * m_fromUtf8 = m_iconv_null
 

Detailed Description

Helper class to deal with recoding the UTF8 encoded text back to the native encoding specified by CHM_INDEX_ENCODING.

Definition at line 42 of file htmlhelp.cpp.

Constructor & Destructor Documentation

◆ HtmlHelpRecoder()

HtmlHelpRecoder::HtmlHelpRecoder ( )
inline

Definition at line 45 of file htmlhelp.cpp.

45{}

◆ ~HtmlHelpRecoder()

HtmlHelpRecoder::~HtmlHelpRecoder ( )
inline

Definition at line 46 of file htmlhelp.cpp.

46{ finalize(); }

References finalize().

Member Function Documentation

◆ finalize()

void HtmlHelpRecoder::finalize ( )
inline

Definition at line 59 of file htmlhelp.cpp.

60 {
62 {
65 }
66 }
void * m_fromUtf8
Definition htmlhelp.cpp:91
void * m_iconv_null
Definition htmlhelp.cpp:90
int portable_iconv_close(void *cd)

References m_fromUtf8, m_iconv_null, and portable_iconv_close().

Referenced by ~HtmlHelpRecoder().

◆ initialize()

void HtmlHelpRecoder::initialize ( )
inline

Definition at line 49 of file htmlhelp.cpp.

50 {
51 QCString str = Config_getString(CHM_INDEX_ENCODING);
52 if (str.isEmpty()) str = "CP1250"; // use safe and likely default
53 m_fromUtf8 = portable_iconv_open(str.data(),"UTF-8");
55 {
56 term("unsupported character conversion for CHM_INDEX_ENCODING: '%s'->'UTF-8'\n", qPrint(str));
57 }
58 }
bool isEmpty() const
Returns TRUE iff the string is empty.
Definition qcstring.h:150
const char * data() const
Returns a pointer to the contents of the string in the form of a 0-terminated C string.
Definition qcstring.h:159
#define Config_getString(name)
Definition config.h:32
#define term(fmt,...)
Definition message.h:94
void * portable_iconv_open(const char *tocode, const char *fromcode)
const char * qPrint(const char *s)
Definition qcstring.h:672

References Config_getString, QCString::data(), initialize(), QCString::isEmpty(), m_fromUtf8, m_iconv_null, portable_iconv_open(), qPrint(), and term.

Referenced by initialize().

◆ recode()

QCString HtmlHelpRecoder::recode ( const QCString & s)
inline

Definition at line 68 of file htmlhelp.cpp.

69 {
70 size_t iSize = s.length();
71 size_t oSize = iSize*4;
72 QCString output(oSize, QCString::ExplicitSize);
73 size_t iLeft = iSize;
74 size_t oLeft = oSize;
75 const char *iPtr = s.data();
76 char *oPtr = output.rawData();
77 if (!portable_iconv(m_fromUtf8,&iPtr,&iLeft,&oPtr,&oLeft))
78 {
79 oSize -= oLeft;
80 output.resize(oSize);
81 output.at(oSize)='\0';
82 return output;
83 }
84 else
85 {
86 return s;
87 }
88 }
size_t length() const
Returns the length of the string, not counting the 0-terminator.
Definition qcstring.h:153
@ ExplicitSize
Definition qcstring.h:133
size_t portable_iconv(void *cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)

References QCString::at(), QCString::data(), QCString::ExplicitSize, QCString::length(), m_fromUtf8, portable_iconv(), QCString::rawData(), and QCString::resize().

Member Data Documentation

◆ m_fromUtf8

void* HtmlHelpRecoder::m_fromUtf8 = m_iconv_null
private

Definition at line 91 of file htmlhelp.cpp.

Referenced by finalize(), initialize(), and recode().

◆ m_iconv_null

void* HtmlHelpRecoder::m_iconv_null = reinterpret_cast<void*>(-1)
private

Definition at line 90 of file htmlhelp.cpp.

Referenced by finalize(), and initialize().


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