org.kde.koala

Class KCodecs

public class KCodecs extends Object implements QtSupport

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. sage:
 String input = "Aladdin:open sesame";
 String 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 byte[] as arguments. These functions are specifically tailored for encoding and decoding binary data.

Author: Rik Hemsley

UNKNOWN: A collection of commonly used encoding and decoding algorithms.

Constructor Summary
protected KCodecs(Class dummy)
Method Summary
static Stringbase64Decode(byte[] in)
Decodes the given data that was encoded using the base64 algorithm.
static Stringbase64Decode(String str)
static voidbase64Decode(byte[] in, byte[] out)
Decodes the given data that was encoded with the base64 algorithm.
static Stringbase64Encode(byte[] in, boolean insertLFs)
Encodes the given data using the base64 algorithm.
static Stringbase64Encode(byte[] in)
static Stringbase64Encode(String str, boolean insertLFs)
static Stringbase64Encode(String str)
static voidbase64Encode(byte[] in, byte[] out, boolean insertLFs)
Encodes the given data using the base64 algorithm.
static voidbase64Encode(byte[] in, byte[] out)
static StringquotedPrintableDecode(byte[] in)
Decodes a quoted-printable encoded data.
static StringquotedPrintableDecode(String str)
static voidquotedPrintableDecode(byte[] in, byte[] out)
Decodes a quoted-printable encoded data.
static StringquotedPrintableEncode(byte[] in, boolean useCRLF)
Encodes the given data using the quoted-printable algorithm.
static StringquotedPrintableEncode(byte[] in)
static StringquotedPrintableEncode(String str, boolean useCRLF)
static StringquotedPrintableEncode(String str)
static voidquotedPrintableEncode(byte[] in, byte[] out, boolean useCRLF)
Encodes the given data using the quoted-printable algorithm.
static Stringuudecode(byte[] in)
Decodes the given data using the uudecode algorithm.
static Stringuudecode(String str)
static voiduudecode(byte[] in, byte[] out)
Decodes the given data using the uudecode algorithm.
static Stringuuencode(byte[] in)
Encodes the given data using the uuencode algorithm.
static Stringuuencode(String str)
static voiduuencode(byte[] in, byte[] out)
Encodes the given data using the uuencode algorithm.

Constructor Detail

KCodecs

protected KCodecs(Class dummy)

Method Detail

base64Decode

public static String base64Decode(byte[] in)
Decodes the given data that was encoded using the base64 algorithm.

Parameters: in data to be decoded.

Returns: decoded string.

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

base64Decode

public static String base64Decode(String str)

Parameters: str string to be decoded.

Returns: decoded string.

UNKNOWN: Same as the above functions except it accepts a null terminated string instead an array. @overload

base64Decode

public static void base64Decode(byte[] in, byte[] 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: in data to be decoded. out decoded data.

UNKNOWN: Decodes the given data that was encoded with the base64 algorithm.

base64Encode

public static String base64Encode(byte[] in, boolean insertLFs)
Encodes the given data using the base64 algorithm. The booleanean 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.

UNKNOWN: Encodes the given data using the base64 algorithm.

base64Encode

public static String base64Encode(byte[] in)

base64Encode

public static String base64Encode(String str, boolean insertLFs)

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

Returns: decoded string.

UNKNOWN: Same as the above functions except it accepts a null terminated string instead an array. @overload

base64Encode

public static String base64Encode(String str)

base64Encode

public static void base64Encode(byte[] in, byte[] out, boolean insertLFs)
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 booleanean 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.

UNKNOWN: Encodes the given data using the base64 algorithm.

base64Encode

public static void base64Encode(byte[] in, byte[] out)

quotedPrintableDecode

public static String quotedPrintableDecode(byte[] in)
Decodes a quoted-printable encoded data. Accepts data with CRLF or standard unix line breaks.

Parameters: in data to be decoded.

Returns: decoded string.

UNKNOWN: Decodes a quoted-printable encoded data.

quotedPrintableDecode

public static String quotedPrintableDecode(String str)

Parameters: str string to be decoded.

Returns: decoded string.

UNKNOWN: Same as above except it accepts a null terminated string instead an array. @overload

quotedPrintableDecode

public static void quotedPrintableDecode(byte[] in, byte[] 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: in data to be decoded. out decoded data.

UNKNOWN: Decodes a quoted-printable encoded data.

quotedPrintableEncode

public static String quotedPrintableEncode(byte[] in, boolean useCRLF)
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.

UNKNOWN: Encodes the given data using the quoted-printable algorithm.

quotedPrintableEncode

public static String quotedPrintableEncode(byte[] in)

quotedPrintableEncode

public static String quotedPrintableEncode(String str, boolean useCRLF)

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.

UNKNOWN: Same as above except it accepts a null terminated string instead an array. @overload

quotedPrintableEncode

public static String quotedPrintableEncode(String str)

quotedPrintableEncode

public static void quotedPrintableEncode(byte[] in, byte[] out, boolean 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: 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.

UNKNOWN: Encodes the given data using the quoted-printable algorithm.

uudecode

public static String uudecode(byte[] 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: in data to be decoded.

Returns: decoded string.

UNKNOWN: Decodes the given data using the uudecode algorithm.

uudecode

public static String uudecode(String str)

Parameters: str string to be decoded.

Returns: uudecoded string.

UNKNOWN: Same as the above functions except it accepts a null terminated string instead an array. @overload

uudecode

public static void uudecode(byte[] in, byte[] 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: in data to be decoded. out uudecoded data.

UNKNOWN: Decodes the given data using the uudecode algorithm.

uuencode

public static String uuencode(byte[] 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: in data to be uuencoded

Returns: uuencoded string.

UNKNOWN: Encodes the given data using the uuencode algorithm.

uuencode

public static String uuencode(String str)

Parameters: str string to be uuencoded.

Returns: encoded string.

UNKNOWN: Same as the above functions except it accepts a null terminated string instead an array. @overload

uuencode

public static void uuencode(byte[] in, byte[] 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: in data to be uuencoded. out uudecoded data.

UNKNOWN: Encodes the given data using the uuencode algorithm.