KMime

kmime_codecs.h
1 /* -*- c++ -*-
2  kmime_codecs.h
3 
4  KMime, the KDE Internet mail/usenet news message library.
5  SPDX-FileCopyrightText: 2001 the KMime authors.
6  See file AUTHORS for details
7 
8  SPDX-License-Identifier: LGPL-2.0-or-later
9 */
10 #pragma once
11 
12 #include <QByteArray>
13 #include <QString>
14 
15 namespace KMime
16 {
17 
18 /**
19  Encodes string @p src according to RFC2047 using charset @p charset.
20 
21  This function also makes commas, quotes and other characters part of the encoded name, for example
22  the string "Jöhn Döe" <[email protected]"> would be encoded as <encoded word for "Jöhn Döe"> <[email protected]>,
23  i.e. the opening and closing quote mark would be part of the encoded word.
24  Therefore don't use this function for input strings that contain semantically meaningful characters,
25  like the quoting marks in this example.
26 
27  @param src source string.
28  @param charset charset to use. If it can't encode the string, UTF-8 will be used instead.
29  @param addressHeader if this flag is true, all special chars
30  like <,>,[,],... will be encoded, too.
31  @param allow8bitHeaders if this flag is true, 8Bit headers are allowed.
32 
33  @return the encoded string.
34 */
35 Q_REQUIRED_RESULT QByteArray encodeRFC2047String(const QString &src, const QByteArray &charset, bool addressHeader = false, bool allow8bitHeaders = false);
36 
37 /**
38  * Same as encodeRFC2047String(), but with a crucial difference: Instead of encoding the complete
39  * string as a single encoded word, the string will be split up at control characters, and only parts of
40  * the sentence that really need to be encoded will be encoded.
41  */
42 Q_REQUIRED_RESULT QByteArray encodeRFC2047Sentence(const QString &src, const QByteArray &charset);
43 
44 /**
45  Decodes string @p src according to RFC2231
46 
47  @param src source string.
48  @param usedCs the detected charset is returned here
49  @param defaultCS the charset to use in case the detected
50  one isn't known to us.
51  @param forceCS force the use of the default charset.
52 
53  @return the decoded string.
54 */
55 Q_REQUIRED_RESULT QString decodeRFC2231String(const QByteArray &src, QByteArray &usedCS, const QByteArray &defaultCS = QByteArray(), bool forceCS = false);
56 
57 /**
58  Encodes string @p src according to RFC2231 using charset @p charset.
59 
60  @param src source string.
61  @param charset charset to use.
62  @return the encoded string.
63 */
64 Q_REQUIRED_RESULT QByteArray encodeRFC2231String(const QString &src, const QByteArray &charset);
65 
66 } // namespace KMime
67 
KIMAP_EXPORT const QString encodeRFC2231String(const QString &str)
KIMAP_EXPORT const QString decodeRFC2231String(const QString &str)
KIMAP_EXPORT const QString encodeRFC2047String(const QString &str)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Sep 27 2021 23:15:57 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.