#include <qmdcodec.h>
Currently there is support for encoding and decoding input using base64, uu and the quoted-printable specifications.
QCString input = "Aladdin:open sesame"; QCString result = QCodecs::base64Encode(input); cout << "Result: " << result.data() << endl;
Output should be Result: QWxhZGRpbjpvcGVuIHNlc2FtZQ==
The above example makes use of the convenience functions (ones that accept/return null-terminated strings) to encode/decode a string. If what you need is to encode or decode binary data, then it is highly recommended that you use the functions that take an input and output QByteArray as arguments. These functions are specifically tailored for encoding and decoding binary data.
A collection of commonly used encoding and decoding algorithms.
Definition at line 73 of file qmdcodec.h.
Static Public Member Functions | |
| static QCString | quotedPrintableEncode (const QByteArray &in, bool useCRLF=true) |
| Encodes the given data using the quoted-printable algorithm. | |
| static QCString | quotedPrintableEncode (const QCString &str, bool useCRLF=true) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as above except it accepts a null terminated string instead an array. | |
| static void | quotedPrintableEncode (const QByteArray &in, QByteArray &out, bool useCRLF) |
| Encodes the given data using the quoted-printable algorithm. | |
| static QCString | quotedPrintableDecode (const QByteArray &in) |
| Decodes a quoted-printable encoded string. | |
| static QCString | quotedPrintableDecode (const QCString &str) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as above except it accepts a null terminated string instead an array. | |
| static void | quotedPrintableDecode (const QByteArray &in, QByteArray &out) |
| Decodes a quoted-printable encoded data. | |
| static QCString | uuencode (const QByteArray &in) |
| Encodes the given data using the uuencode algorithm. | |
| static QCString | uuencode (const QCString &str) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as the above functions except it accepts a null terminated string instead an array. | |
| static void | uuencode (const QByteArray &in, QByteArray &out) |
| Encodes the given data using the uuencode algorithm. | |
| static QCString | uudecode (const QByteArray &in) |
| Decodes the given data using the uuencode algorithm. | |
| static QCString | uudecode (const QCString &str) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as the above functions except it accepts a null terminated string instead an array. | |
| static void | uudecode (const QByteArray &in, QByteArray &out) |
| Decodes the given data using the uudecode algorithm. | |
| static QCString | base64Encode (const QByteArray &in, bool insertLFs=false) |
| Encodes the given data using the base64 algorithm. | |
| static QCString | base64Encode (const QCString &str, bool insertLFs=false) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as the above functions except it accepts a null terminated string instead an array. | |
| static void | base64Encode (const QByteArray &in, QByteArray &out, bool insertLFs=false) |
| Encodes the given data using the base64 algorithm. | |
| static QCString | base64Decode (const QByteArray &in) |
| Decodes the given data that was encoded using the base64 algorithm. | |
| static QCString | base64Decode (const QCString &str) |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as the above functions except it accepts a null terminated string instead an array. | |
| static void | base64Decode (const QByteArray &in, QByteArray &out) |
| Decodes the given data that was encoded with the base64 algorithm. | |
Private Member Functions | |
| QCodecs () | |
Static Private Attributes | |
| static const char | UUEncMap [64] |
| static const char | UUDecMap [128] |
| static const char | Base64EncMap [64] |
| static const char | Base64DecMap [128] |
| static const char | hexChars [16] |
| static const unsigned int | maxQPLineLength = 70 |
| QCodecs::QCodecs | ( | ) | [private] |
| QCString QCodecs::quotedPrintableEncode | ( | const QByteArray & | in, | |
| bool | useCRLF = true | |||
| ) | [static] |
Encodes the given data using the quoted-printable algorithm.
| in | data to be encoded. | |
| useCRLF | if true the input data is expected to have CRLF line breaks and the output will have CRLF line breaks, too. |
Definition at line 147 of file qmdcodec.cpp.
Referenced by quotedPrintableEncode().
| QCString QCodecs::quotedPrintableEncode | ( | const QCString & | str, | |
| bool | useCRLF = true | |||
| ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as above except it accepts a null terminated string instead an array.
| str | data to be encoded. | |
| useCRLF | if true the input data is expected to have CRLF line breaks and the output will have CRLF line breaks, too. |
Definition at line 154 of file qmdcodec.cpp.
| void QCodecs::quotedPrintableEncode | ( | const QByteArray & | in, | |
| QByteArray & | out, | |||
| bool | useCRLF | |||
| ) | [static] |
Encodes the given data using the quoted-printable algorithm.
Use this function if you want the result of the encoding to be placed in another array which cuts down the number of copy operation that have to be performed in the process. This is also the preferred method for encoding binary data.
NOTE: the output array is first reset and then resized appropriately before use, hence, all data stored in the output array will be lost.
| in | data to be encoded. | |
| out | decoded data. | |
| useCRLF | if true the input data is expected to have CRLF line breaks and the output will have CRLF line breaks, too. |
Definition at line 164 of file qmdcodec.cpp.
| QCString QCodecs::quotedPrintableDecode | ( | const QByteArray & | in | ) | [static] |
Decodes a quoted-printable encoded string.
Accepts data with CRLF or standard unix line breaks.
| in | the data to be decoded. |
Definition at line 280 of file qmdcodec.cpp.
Referenced by quotedPrintableDecode().
| QCString QCodecs::quotedPrintableDecode | ( | const QCString & | str | ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as above except it accepts a null terminated string instead an array.
| str | the data to be decoded. |
Definition at line 287 of file qmdcodec.cpp.
| void QCodecs::quotedPrintableDecode | ( | const QByteArray & | in, | |
| QByteArray & | out | |||
| ) | [static] |
Decodes a quoted-printable encoded data.
Accepts data with CRLF or standard unix line breaks. Use this function if you want the result of the decoding to be placed in another array which cuts down the number of copy operation that have to be performed in the process. This is also the preferred method for decoding an encoded binary data.
NOTE: the output array is first reset and then resized appropriately before use, hence, all data stored in the output array will be lost.
| in | data to be encoded. | |
| out | decoded data. |
Definition at line 297 of file qmdcodec.cpp.
| QCString QCodecs::uuencode | ( | const QByteArray & | in | ) | [static] |
Encodes the given data using the uuencode algorithm.
The output is split into lines starting with the number of encoded octets in the line and ending with a newline. No line is longer than 45 octets (60 characters), excluding the line terminator.
| in | the data to be uuencoded |
Definition at line 557 of file qmdcodec.cpp.
Referenced by uuencode().
| QCString QCodecs::uuencode | ( | const QCString & | str | ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as the above functions except it accepts a null terminated string instead an array.
| str | the string to be uuencoded. |
Definition at line 546 of file qmdcodec.cpp.
| void QCodecs::uuencode | ( | const QByteArray & | in, | |
| QByteArray & | out | |||
| ) | [static] |
Encodes the given data using the uuencode algorithm.
Use this function if you want the result of the encoding to be placed in another array and cut down the number of copy operation that have to be performed in the process. This is the preffered method for encoding binary data.
NOTE: the output array is first reset and then resized appropriately before use, hence, all data stored in the output array will be lost.
| in | the data to be uuencoded. | |
| out | the container for the uudecoded data. |
Definition at line 564 of file qmdcodec.cpp.
| QCString QCodecs::uudecode | ( | const QByteArray & | in | ) | [static] |
Decodes the given data using the uuencode algorithm.
Any 'begin' and 'end' lines like those generated by the utilities in unix and unix-like OS will be automatically ignored.
| in | the data uuencoded data to be decoded. |
Definition at line 654 of file qmdcodec.cpp.
Referenced by uudecode().
| QCString QCodecs::uudecode | ( | const QCString & | str | ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as the above functions except it accepts a null terminated string instead an array.
| str | the string to be decoded. |
Definition at line 643 of file qmdcodec.cpp.
| void QCodecs::uudecode | ( | const QByteArray & | in, | |
| QByteArray & | out | |||
| ) | [static] |
Decodes the given data using the uudecode algorithm.
Use this function if you want the result of the decoding to be placed in another array which cuts down the number of copy operation that have to be performed in the process. This is the preferred method for decoding binary data.
Any 'begin' and 'end' lines like those generated by the utilities in unix and unix-like OS will be automatically ignored.
NOTE: the output array is first reset and then resized appropriately before use, hence, all data stored in the output array will be lost.
| in | the uuencoded-data to be decoded. | |
| out | the container for the uudecoded data. |
Definition at line 661 of file qmdcodec.cpp.
| QCString QCodecs::base64Encode | ( | const QByteArray & | in, | |
| bool | insertLFs = false | |||
| ) | [static] |
Encodes the given data using the base64 algorithm.
The boolean argument determines if the encoded data is going to be restricted to 76 characters or less per line as specified by RFC 2045. If insertLFs is true, then there will be 76 characters or less per line.
| in | the data to be encoded. | |
| insertLFs | limit the number of characters per line. |
Definition at line 365 of file qmdcodec.cpp.
Referenced by QMD5::base64Digest(), base64Encode(), and HttpComms::headerReceived().
| QCString QCodecs::base64Encode | ( | const QCString & | str, | |
| bool | insertLFs = false | |||
| ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as the above functions except it accepts a null terminated string instead an array.
| str | the string to be encoded. | |
| insertLFs | limit the number of characters per line. |
Definition at line 355 of file qmdcodec.cpp.
| void QCodecs::base64Encode | ( | const QByteArray & | in, | |
| QByteArray & | out, | |||
| bool | insertLFs = false | |||
| ) | [static] |
Encodes the given data using the base64 algorithm.
Use this function if you want the result of the encoding to be placed in another array which cuts down the number of copy operation that have to be performed in the process. This is also the preferred method for encoding binary data.
The boolean argument determines if the encoded data is going to be restricted to 76 characters or less per line as specified by RFC 2045. If insertLFs is true, then there will be 76 characters or less per line.
NOTE: the output array is first reset and then resized appropriately before use, hence, all data stored in the output array will be lost.
| in | the data to be encoded using base64. | |
| out | the container for the encoded data. | |
| insertLFs | limit the number of characters per line. |
Definition at line 372 of file qmdcodec.cpp.
| QCString QCodecs::base64Decode | ( | const QByteArray & | in | ) | [static] |
Decodes the given data that was encoded using the base64 algorithm.
| in | the base64-encoded data to be decoded. |
Definition at line 454 of file qmdcodec.cpp.
Referenced by base64Decode().
| QCString QCodecs::base64Decode | ( | const QCString & | str | ) | [static] |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Same as the above functions except it accepts a null terminated string instead an array.
| str | the base64-encoded string. |
Definition at line 444 of file qmdcodec.cpp.
| void QCodecs::base64Decode | ( | const QByteArray & | in, | |
| QByteArray & | out | |||
| ) | [static] |
Decodes the given data that was encoded with the base64 algorithm.
Use this function if you want the result of the decoding to be placed in another array which cuts down the number of copy operation that have to be performed in the process. This is also the preferred method for decoding an encoded binary data.
NOTE: the output array is first reset and then resized appropriately before use, hence, all data stored in the output array will be lost.
| in | the encoded data to be decoded. | |
| out | the container for the decoded data. |
Definition at line 461 of file qmdcodec.cpp.
const char QCodecs::UUEncMap [static, private] |
Initial value:
{
0x60, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F
}
Definition at line 350 of file qmdcodec.h.
Referenced by uuencode().
const char QCodecs::UUDecMap [static, private] |
Initial value:
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
}
Definition at line 351 of file qmdcodec.h.
Referenced by uudecode().
const char QCodecs::Base64EncMap [static, private] |
Initial value:
{
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E,
0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F
}
Definition at line 352 of file qmdcodec.h.
Referenced by base64Encode().
const char QCodecs::Base64DecMap [static, private] |
Initial value:
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F,
0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00
}
Definition at line 353 of file qmdcodec.h.
Referenced by base64Decode().
const char QCodecs::hexChars [static, private] |
Initial value:
{
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
}
Definition at line 354 of file qmdcodec.h.
Referenced by quotedPrintableDecode(), and quotedPrintableEncode().
const unsigned int QCodecs::maxQPLineLength = 70 [static, private] |
1.5.5