# kdecore Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# KCodecs Class Reference

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

`#include <kmdcodec.h>`

List of all members.

## Static Public Member Functions

static QCString | quotedPrintableEncode (const QByteArray &in, bool useCRLF=true)
static QCString | quotedPrintableEncode (const QCString &str, bool useCRLF=true)
static void | quotedPrintableEncode (const QByteArray &in, QByteArray &out, bool useCRLF)
static QCString | quotedPrintableDecode (const QByteArray &in)
static QCString | quotedPrintableDecode (const QCString &str)
static void | quotedPrintableDecode (const QByteArray &in, QByteArray &out)
static QCString | uuencode (const QByteArray &in)
static QCString | uuencode (const QCString &str)
static void | uuencode (const QByteArray &in, QByteArray &out)
static QCString | uudecode (const QByteArray &in)
static QCString | uudecode (const QCString &str)
static void | uudecode (const QByteArray &in, QByteArray &out)
static QCString | base64Encode (const QByteArray &in, bool insertLFs=false)
static QCString | base64Encode (const QCString &str, bool insertLFs=false)
static void | base64Encode (const QByteArray &in, QByteArray &out, bool insertLFs=false)
static QCString | base64Decode (const QByteArray &in)
static QCString | base64Decode (const QCString &str)
static void | base64Decode (const QByteArray &in, QByteArray &out)

## Detailed Description

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

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

Usage:

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

Author:
  Dawit Alemayehu <adawit@kde.org>

  Rik Hemsley <rik@kde.org>

Definition at line 74 of file kmdcodec.h.

## Member Function Documentation

QCString KCodecs::quotedPrintableEncode | ( | const QByteArray & | in,
|  | bool | useCRLF = `true`
| ) | `[static]`

Encodes the given data using the quoted-printable algorithm.

Parameters:

  | 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.

Returns:
  quoted-printable encoded string.

Definition at line 154 of file kmdcodec.cpp.

Referenced by quotedPrintableEncode().

QCString KCodecs::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.

Parameters:

  | str | string 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.

Returns:
  quoted-printable encoded string.

Definition at line 161 of file kmdcodec.cpp.

References quotedPrintableEncode().

void KCodecs::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.

Parameters:

  | in | data to be encoded.
  | out | encoded 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 171 of file kmdcodec.cpp.

References QCString::resize().

QCString KCodecs::quotedPrintableDecode | ( | const QByteArray & | in | ) | `[static]`

Decodes a quoted-printable encoded data.

Accepts data with CRLF or standard unix line breaks.

Parameters:

  | in | data to be decoded.

Returns:
  decoded string.

Definition at line 287 of file kmdcodec.cpp.

Referenced by quotedPrintableDecode().

QCString KCodecs::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.

Parameters:

  | str | string to be decoded.

Returns:
  decoded string.

Definition at line 294 of file kmdcodec.cpp.

References quotedPrintableDecode().

void KCodecs::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.

Parameters:

  | in | data to be decoded.
  | out | decoded data.

Definition at line 304 of file kmdcodec.cpp.

References QCString::resize(), and QCString::truncate().

QCString KCodecs::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.

Parameters:

  | in | data to be uuencoded

Returns:
  uuencoded string.

Definition at line 560 of file kmdcodec.cpp.

Referenced by uuencode().

QCString KCodecs::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.

Parameters:

  | str | string to be uuencoded.

Returns:
  encoded string.

Definition at line 549 of file kmdcodec.cpp.

References uuencode().

void KCodecs::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.

Parameters:

  | in | data to be uuencoded.
  | out | uudecoded data.

Definition at line 567 of file kmdcodec.cpp.

References QCString::resize().

QCString KCodecs::uudecode | ( | const QByteArray & | in | ) | `[static]`

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:

  | in | data to be decoded.

Returns:
  decoded string.

Definition at line 657 of file kmdcodec.cpp.

Referenced by uudecode().

QCString KCodecs::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.

Parameters:

  | str | string to be decoded.

Returns:
  uudecoded string.

Definition at line 646 of file kmdcodec.cpp.

References uudecode().

void KCodecs::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.

Parameters:

  | in | data to be decoded.
  | out | uudecoded data.

Definition at line 664 of file kmdcodec.cpp.

References QCString::resize().

QCString KCodecs::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.

Parameters:

  | in | data to be encoded.
  | insertLFs | limit the number of characters per line.

Returns:
  base64 encoded string.

Definition at line 372 of file kmdcodec.cpp.

Referenced by KMD4::base64Digest(), KMD5::base64Digest(), and base64Encode().

QCString KCodecs::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.

Parameters:

  | str | string to be encoded.
  | insertLFs | limit the number of characters per line.

Returns:
  decoded string.

Definition at line 362 of file kmdcodec.cpp.

References base64Encode().

void KCodecs::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.

Parameters:

  | in | data to be encoded.
  | out | encoded data.
  | insertLFs | limit the number of characters per line.

Definition at line 379 of file kmdcodec.cpp.

References QCString::resize().

QCString KCodecs::base64Decode | ( | const QByteArray & | in | ) | `[static]`

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

Parameters:

  | in | data to be decoded.

Returns:
  decoded string.

Definition at line 461 of file kmdcodec.cpp.

Referenced by base64Decode().

QCString KCodecs::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.

Parameters:

  | str | string to be decoded.

Returns:
  decoded string.

Definition at line 451 of file kmdcodec.cpp.

References base64Decode().

void KCodecs::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.

Parameters:

  | in | data to be decoded.
  | out | decoded data.

Definition at line 468 of file kmdcodec.cpp.

References QCString::resize().

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

- kmdcodec.h
- kmdcodec.cpp

This file is part of the documentation for kdecore Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:18:21 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003