16 #ifndef __KMIME_UTIL_H__
17 #define __KMIME_UTIL_H__
19 #include "tqdatetime.h"
21 #include "tqcstring.h"
22 #include "tqvaluelist.h"
24 #include <tdemacros.h>
26 typedef TQValueList<TQCString> QCStringList;
32 extern const char* cachedCharset(
const TQCString &name) TDE_EXPORT;
36 extern const char* cachedLanguage(
const TQCString &name) TDE_EXPORT;
39 extern bool isUsAscii(
const TQString &s) TDE_EXPORT;
41 inline bool isOfSet(
const uchar map[16],
unsigned char ch) {
43 return ( map[ ch/8 ] & 0x80 >> ch%8 );
46 extern const uchar specialsMap[16];
47 extern const uchar tSpecialsMap[16];
48 extern const uchar aTextMap[16];
49 extern const uchar tTextMap[16];
50 extern const uchar eTextMap[16];
52 inline bool isSpecial(
char ch) {
53 return isOfSet( specialsMap, ch );
55 inline bool isTSpecial(
char ch) {
56 return isOfSet( tSpecialsMap, ch );
58 inline bool isAText(
char ch) {
59 return isOfSet( aTextMap, ch );
61 inline bool isTText(
char ch) {
62 return isOfSet( tTextMap, ch );
64 inline bool isEText(
char ch) {
65 return isOfSet( eTextMap, ch );
77 extern TQString decodeRFC2047String(
const TQCString &src,
const char **usedCS,
78 const TQCString &defaultCS,
bool forceCS) TDE_EXPORT;
85 extern TQString decodeRFC2047String(
const TQCString &src) TDE_EXPORT;
97 extern TQCString encodeRFC2047String(
const TQString &src,
const char *charset,
98 bool addressHeader=
false,
bool allow8bitHeaders=
false) TDE_EXPORT;
106 extern TQCString uniqueString() TDE_EXPORT;
114 extern TQCString multiPartBoundary() TDE_EXPORT;
123 extern TQCString extractHeader(const TQCString &src, const
char *name) TDE_EXPORT;
133 extern TQCString CRLFtoLF(const TQCString &s) TDE_EXPORT;
143 extern TQCString CRLFtoLF(const
char *s) TDE_EXPORT;
155 extern TQCString LFtoCRLF(const TQCString &s) TDE_EXPORT;
162 TDE_EXPORT extern
void removeQuots(TQCString &str);
168 TDE_EXPORT extern
void removeQuots(TQString &str);
175 TDE_EXPORT extern
void addQuotes(TQCString &str,
bool forceQuotes);
215 FormatType getFormat()
const;
219 void setFormat(FormatType t);
229 TQString dateString(time_t otime,
const TQString& lang = TQString(),
230 bool shortFormat =
true,
bool includeSecs=
false)
const;
234 TQString dateString(
const TQDateTime& dtime,
const TQString& lang = TQString(),
235 bool shortFormat =
true,
bool includeSecs=
false)
const;
247 void setCustomFormat(
const TQString& format);
248 TQString getCustomFormat()
const;
254 TQCString rfc2822(time_t otime)
const;
269 static TQString formatDate( DateFormatter::FormatType t, time_t time,
270 const TQString& data = TQString(),
271 bool shortFormat =
true,
bool includeSecs=
false);
281 static TQString formatCurrentDate( DateFormatter::FormatType t,
282 const TQString& data = TQString(),
283 bool shortFormat =
true,
bool includeSecs=
false);
286 static TQCString rfc2822FormatDate( time_t time );
287 static bool isDaylight();
294 TQString fancy(time_t otime)
const ;
303 TQString localized(time_t otime,
bool shortFormat =
true,
bool includeSecs =
false,
304 const TQString& localeLanguage=TQString() )
const;
309 TQString cTime(time_t otime)
const;
314 TQString isoDate(time_t otime)
const;
322 TQString custom(time_t t)
const;
327 TQCString zone(time_t otime)
const;
329 time_t qdateToTimeT(
const TQDateTime& dt)
const;
332 mutable time_t mCurrentTime;
333 mutable TQDateTime mDate;
334 TQString mCustomFormat;
335 static int mDaylight;