DCL 3.7.4
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 116 of file TransferEncoding.cpp.

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

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