KIMAP
Go to the documentation of this file.
37static const unsigned char base64chars[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
40static 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];
qsizetype length() const const
void reserve(qsizetype size)
QString fromUtf8(QByteArrayView str)
qsizetype length() const const
void reserve(qsizetype size)
QByteArray toUtf8() const const
This file is part of the IMAP support library and defines the RfcCodecs class.
KIMAP_EXPORT QString quoteIMAP(const QString &src)
Replaces " with \" and \ with \\ " and \ characters.
KIMAP_EXPORT QByteArray decodeImapFolderName(const QByteArray &inSrc)
Converts an UTF-7 encoded IMAP mailbox to a QByteArray.
KIMAP_EXPORT QByteArray encodeImapFolderName(const QByteArray &src)
Converts an Unicode IMAP mailbox to a QByteArray which can be used in IMAP communication.
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 31 2025 12:04:47 by
doxygen 1.13.2 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.