DCL 4.0
Loading...
Searching...
No Matches
QuotedPrintableDecoder Class Reference

#include <TransferEncoding.h>

Static Public Member Functions

static ByteString decode (const ByteString &_str)

Detailed Description

Definition at line 31 of file TransferEncoding.h.

Member Function Documentation

◆ decode()

ByteString QuotedPrintableDecoder::decode ( const ByteString & _str)
static

Definition at line 122 of file TransferEncoding.cpp.

123{
124 __DCL_ASSERT(_str.length() > 0);
125
126 const byte_t* src = (byte_t*)_str.data();
127 ByteBuffer* buf = ByteBuffer::create(_str.length()); // + 1);
128 byte_t* dest = (byte_t*) buf->data();
129
130 size_t i = 0;
131 size_t j = 0;
132 while(src[i])
133 {
134 if ('=' == src[i])
135 {
136 // quotered character
137
138 if (src[i + 1] && src[i + 2]
139 && isxdigit(src[i + 1]) && isxdigit(src[i + 2]))
140 {
141 dest[j++] = (hex2int(src[i + 1]) << 4)
142 + hex2int(src[i + 2]);
143 i += 3;
144 }
145 else
146 {
147 // check for soft line break
148 int k = 1;
149 while(src[i + k] &&
150 ((src[i + k] == ' ') || (src[i + k] == TAB)))
151 {
152 // skip space or tab character
153 k++;
154 }
155
156 if (!src[i + k])
157 i += k; // end of line reached
158 else if ((src[i + k] == CR) && (src[i + k + 1] == LF))
159 i += k + 2; // CRLF
160 else if ((src[i + k] == CR) || (src[i + k] == LF))
161 i += k + 1; // CR or LF
162 else
163 dest[j++] = src[i++];
164 }
165 }
166 else
167 {
168 // literal
169 dest[j++] = src[i++];
170 }
171 }
172
173 dest[j] = __T('\0');
174 __DCL_ASSERT(j <= buf->__allocLength);
175 buf->__dataLength = j;
176
177 ByteString r = buf;
178 buf->release();
179 return r;
180}
unsigned char byte_t
Definition Config.h:274
#define LF
#define CR
#define __DCL_ASSERT(expr)
Definition Object.h:371
#define __T(str)
Definition Object.h:44
ByteString r
ByteBuffer * buf
char hex2int(int c)
#define TAB

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