Convert a hzChain whose content is presumed to encoded using the Quoted-Printable method, back to it's original form.
| Return Type | Function name | Arguments |
|---|---|---|
| hzEcode | QPDecode | (hzChain&,hzChain&,) |
Declared in file: hzCodec.h
Defined in file : hzCodec.cpp
Function Logic:
Function body:
hzEcode QPDecode (hzChain& Decoded)hzChain& Raw,
{
// Category: Codec
//
// Convert a hzChain whose content is presumed to encoded using the Quoted-Printable method, back to it's original form.
//
// Arguments: 1) Decoded The hzChain reference that will contain the result. Any pre-existing contents of this are cleared at the outset.
// 2) Raw The encoded hzChain. This is not altered by this operation.
//
// Returns: E_NODATA If the encoded chain is empty
// E_FORMAT If there is an error in conversion
// E_OK If the operation is successful
_hzfunc("QPDecode") ;
chIter zi ; // Iterator
int32_t val ; // Holds 24 bit value to be written as 3 bytes
Decoded.Clear() ;
if (!Raw.Size())
return E_NODATA ;
// Interate the input. On the occurence of '=', the next two bytes are hex for the actual char.
zi = Raw ;
for (; !zi.eof() ;)
{
if (*zi == CHAR_EQUAL)
{
zi++ ;
if (*zi == CHAR_CR || *zi == CHAR_NL)
{
// Just skip to next line
if (*zi == CHAR_CR) zi++ ;
if (*zi == CHAR_NL) zi++ ;
continue ;
}
if (zi.eof() || !IsHex(*zi))
return E_FORMAT ;
val = _get1hex(*zi) ;
zi++ ;
if (zi.eof() || !IsHex(*zi))
return E_FORMAT ;
val *= 16;
val += _get1hex(*zi) ;
Decoded.AddByte(val) ;
zi++ ;
continue ;
}
Decoded.AddByte(*zi) ;
zi++ ;
}
return E_OK ;
}