• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

Functions | Variables
KCodecs Namespace Reference

Functions

QByteArray base64Decode (const QByteArray &in)
 
void base64Decode (const QByteArray &in, QByteArray &out)
 
QByteArray base64Encode (const QByteArray &in, bool insertLFs=false)
 
void base64Encode (const QByteArray &in, QByteArray &out, bool insertLFs=false)
 
QString decodeRFC2047String (const QString &text)
 
QByteArray quotedPrintableDecode (const QByteArray &in)
 
void quotedPrintableDecode (const QByteArray &in, QByteArray &out)
 
QByteArray quotedPrintableEncode (const QByteArray &in, bool useCRLF=true)
 
void quotedPrintableEncode (const QByteArray &in, QByteArray &out, bool useCRLF)
 
QByteArray uudecode (const QByteArray &in)
 
void uudecode (const QByteArray &in, QByteArray &out)
 
QByteArray uuencode (const QByteArray &in)
 
void uuencode (const QByteArray &in, QByteArray &out)
 

Variables

static const char Base64DecMap [128]
 
static const char Base64EncMap [64]
 
static const char hexChars [16]
 
static const unsigned int maxQPLineLength = 70
 
static const char UUDecMap [128]
 
static const char UUEncMap [64]
 

Detailed Description

A wrapper class for the most commonly used encoding and decoding algorithms.

Currently there is support for encoding and decoding input using base64, uu and the quoted-printable specifications.

Usage:

QByteArray input = "Aladdin:open sesame";
QByteArray result = KCodecs::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.

Author
Dawit Alemayehu adawi.nosp@m.t@kd.nosp@m.e.org
Rik Hemsley rik@k.nosp@m.de.o.nosp@m.rg

Function Documentation

QByteArray KCodecs::base64Decode ( const QByteArray &  in)

Decodes the given data that was encoded using the base64 algorithm.

Parameters
indata to be decoded.
Returns
decoded string.

Definition at line 424 of file kcodecs.cpp.

void KCodecs::base64Decode ( const QByteArray &  in,
QByteArray &  out 
)

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.

Parameters
indata to be decoded.
outdecoded data.

Definition at line 431 of file kcodecs.cpp.

QByteArray KCodecs::base64Encode ( const QByteArray &  in,
bool  insertLFs = false 
)

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.

Parameters
indata to be encoded.
insertLFslimit the number of characters per line.
Returns
base64 encoded string.

Definition at line 345 of file kcodecs.cpp.

void KCodecs::base64Encode ( const QByteArray &  in,
QByteArray &  out,
bool  insertLFs = false 
)

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.

Parameters
indata to be encoded.
outencoded data.
insertLFslimit the number of characters per line.

Definition at line 352 of file kcodecs.cpp.

QString KCodecs::decodeRFC2047String ( const QString &  text)

Decodes string text according to RFC2047, i.e., the construct =?charset?[qb]?encoded?=.

Note: a more rubust version of this function is included in kdepimlibs/libkmime

Parameters
textsource string
Returns
the decoded string

Definition at line 693 of file kcodecs.cpp.

QByteArray KCodecs::quotedPrintableDecode ( const QByteArray &  in)

Decodes a quoted-printable encoded data.

Accepts data with CRLF or standard unix line breaks.

Parameters
indata to be decoded.
Returns
decoded string.

Definition at line 279 of file kcodecs.cpp.

void KCodecs::quotedPrintableDecode ( const QByteArray &  in,
QByteArray &  out 
)

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.

Parameters
indata to be decoded.
outdecoded data.

Definition at line 287 of file kcodecs.cpp.

QByteArray KCodecs::quotedPrintableEncode ( const QByteArray &  in,
bool  useCRLF = true 
)

Encodes the given data using the quoted-printable algorithm.

Parameters
indata to be encoded.
useCRLFif true the input data is expected to have CRLF line breaks and the output will have CRLF line breaks, too.
Returns
quoted-printable encoded string.

Definition at line 156 of file kcodecs.cpp.

void KCodecs::quotedPrintableEncode ( const QByteArray &  in,
QByteArray &  out,
bool  useCRLF 
)

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.

Parameters
indata to be encoded.
outencoded data.
useCRLFif true the input data is expected to have CRLF line breaks and the output will have CRLF line breaks, too.

Definition at line 163 of file kcodecs.cpp.

QByteArray KCodecs::uudecode ( const QByteArray &  in)

Decodes the given data using the uudecode algorithm.

Any 'begin' and 'end' lines like those generated by the utilities in unix and unix-like OS will be automatically ignored.

Parameters
indata to be decoded.
Returns
decoded string.

Definition at line 598 of file kcodecs.cpp.

void KCodecs::uudecode ( const QByteArray &  in,
QByteArray &  out 
)

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.

Parameters
indata to be decoded.
outuudecoded data.

Definition at line 605 of file kcodecs.cpp.

QByteArray KCodecs::uuencode ( const QByteArray &  in)

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.

Parameters
indata to be uuencoded
Returns
uuencoded string.

Definition at line 512 of file kcodecs.cpp.

void KCodecs::uuencode ( const QByteArray &  in,
QByteArray &  out 
)

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.

Parameters
indata to be uuencoded.
outuudecoded data.

Definition at line 519 of file kcodecs.cpp.

Variable Documentation

const char KCodecs::Base64DecMap[128]
static
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 76 of file kcodecs.cpp.

const char KCodecs::Base64EncMap[64]
static
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 64 of file kcodecs.cpp.

const char KCodecs::hexChars[16]
static
Initial value:
=
{
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
}

Definition at line 128 of file kcodecs.cpp.

const unsigned int KCodecs::maxQPLineLength = 70
static

Definition at line 134 of file kcodecs.cpp.

const char KCodecs::UUDecMap[128]
static
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 108 of file kcodecs.cpp.

const char KCodecs::UUEncMap[64]
static
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 96 of file kcodecs.cpp.

This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:13 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal