KIMAP
Go to the documentation of this file.
23 #include <sys/types.h>
29 #include <QLatin1Char>
31 using namespace KIMAP;
37 static const unsigned char base64chars[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
40 static const char especials[17] =
"()<>@,;:\"/[]?.= ";
43 #define UTF16MASK 0x03FFUL
45 #define UTF16BASE 0x10000UL
46 #define UTF16HIGHSTART 0xD800UL
47 #define UTF16HIGHEND 0xDBFFUL
48 #define UTF16LOSTART 0xDC00UL
49 #define UTF16LOEND 0xDFFFUL
57 unsigned char bitcount;
61 unsigned char base64[256];
62 unsigned char utf8[6];
63 unsigned int srcPtr = 0;
66 uint srcLen = inSrc.
length();
69 memset(base64, UNDEFINED,
sizeof(base64));
70 for (i = 0; i <
sizeof(base64chars); ++i) {
71 base64[(int)base64chars[i]] = i;
75 while (srcPtr < srcLen) {
78 if (c !=
'&' || src[srcPtr] ==
'-') {
90 while ((c = base64[(
unsigned char)src[srcPtr]]) != UNDEFINED) {
92 bitbuf = (bitbuf << 6) | c;
97 utf16 = (bitcount ? bitbuf >> bitcount : bitbuf) & 0xffff;
99 if (utf16 >= UTF16HIGHSTART && utf16 <= UTF16HIGHEND) {
100 ucs4 = (utf16 - UTF16HIGHSTART) << UTF16SHIFT;
102 }
else if (utf16 >= UTF16LOSTART && utf16 <= UTF16LOEND) {
103 ucs4 += utf16 - UTF16LOSTART + UTF16BASE;
108 if (ucs4 <= 0x7fUL) {
111 }
else if (ucs4 <= 0x7ffUL) {
112 utf8[0] = 0xc0 | (ucs4 >> 6);
113 utf8[1] = 0x80 | (ucs4 & 0x3f);
115 }
else if (ucs4 <= 0xffffUL) {
116 utf8[0] = 0xe0 | (ucs4 >> 12);
117 utf8[1] = 0x80 | ((ucs4 >> 6) & 0x3f);
118 utf8[2] = 0x80 | (ucs4 & 0x3f);
121 utf8[0] = 0xf0 | (ucs4 >> 18);
122 utf8[1] = 0x80 | ((ucs4 >> 12) & 0x3f);
123 utf8[2] = 0x80 | ((ucs4 >> 6) & 0x3f);
124 utf8[3] = 0x80 | (ucs4 & 0x3f);
128 for (c = 0; c < i; ++c) {
134 if (src[srcPtr] ==
'-') {
154 for (
int i = 0; i < len; i++) {
155 if (src[i] ==
'"' || src[i] ==
'\\') {
169 for (
unsigned int i = 0; i < len; i++) {
187 unsigned int utf8pos;
188 unsigned int utf8total;
190 unsigned int utf7mode;
191 unsigned int bitstogo;
192 unsigned int utf16flag;
205 while (srcPtr < src.
length()) {
206 c = (
unsigned char)src[srcPtr++];
208 if (c >=
' ' && c <=
'~') {
212 dst += base64chars[(bitbuf << (6 - bitstogo)) & 0x3F];
234 }
else if (utf8total) {
236 ucs4 = (ucs4 << 6) | (c & 0x3FUL);
237 if (++utf8pos < utf8total) {
245 }
else if (c < 0xF0) {
258 if (ucs4 >= UTF16BASE) {
260 bitbuf = (bitbuf << 16) | ((ucs4 >> UTF16SHIFT) + UTF16HIGHSTART);
261 ucs4 = (ucs4 & UTF16MASK) + UTF16LOSTART;
264 bitbuf = (bitbuf << 16) | ucs4;
269 while (bitstogo >= 6) {
271 dst += base64chars[(bitstogo ? (bitbuf >> bitstogo) : bitbuf) & 0x3F];
278 dst += base64chars[(bitbuf << (6 - bitstogo)) & 0x3F];
KIMAP_EXPORT QString encodeImapFolderName(const QString &src)
Converts an Unicode IMAP mailbox to a QString which can be used in IMAP communication.
KIMAP2_EXPORT QByteArray encodeImapFolderName(const QByteArray &src)
Converts an Unicode IMAP mailbox to a QByteArray which can be used in IMAP communication.
QString fromUtf8(const char *str, int size)
KIMAP_EXPORT QByteArray quoteIMAP(const QByteArray &src)
Replaces " with \" and \ with \ " and \ characters.
KIMAP2_EXPORT QByteArray decodeImapFolderName(const QByteArray &inSrc)
Converts an UTF-7 encoded IMAP mailbox to a QByteArray.
QByteArray toUtf8() const const
KIMAP_EXPORT QString decodeImapFolderName(const QString &inSrc)
Converts an UTF-7 encoded IMAP mailbox to a Unicode QString.
const char * constData() const const
KIMAP2_EXPORT QByteArray quoteIMAP(const QByteArray &src)
Replaces " with \" and \ with \ " and \ characters.
Provides handlers for various RFC/MIME encodings.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Tue Dec 5 2023 04:10:03 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.