File indexing completed on 2024-04-28 16:37:46
0001 /* -*- c++ -*- 0002 kmime_codecs.h 0003 0004 KMime, the KDE Internet mail/usenet news message library. 0005 SPDX-FileCopyrightText: 2001 the KMime authors. 0006 See file AUTHORS for details 0007 0008 SPDX-License-Identifier: LGPL-2.0-or-later 0009 */ 0010 #pragma once 0011 0012 #include <QByteArray> 0013 #include <QString> 0014 0015 namespace KMime 0016 { 0017 0018 /** 0019 Encodes string @p src according to RFC2047 using charset @p charset. 0020 0021 This function also makes commas, quotes and other characters part of the encoded name, for example 0022 the string "Jöhn Döe" <john@example.com"> would be encoded as <encoded word for "Jöhn Döe"> <john@example.com>, 0023 i.e. the opening and closing quote mark would be part of the encoded word. 0024 Therefore don't use this function for input strings that contain semantically meaningful characters, 0025 like the quoting marks in this example. 0026 0027 @param src source string. 0028 @param charset charset to use. If it can't encode the string, UTF-8 will be used instead. 0029 @param addressHeader if this flag is true, all special chars 0030 like <,>,[,],... will be encoded, too. 0031 0032 @return the encoded string. 0033 */ 0034 [[nodiscard]] QByteArray encodeRFC2047String(QStringView src, 0035 const QByteArray &charset, 0036 bool addressHeader = false); 0037 0038 /** 0039 * Same as encodeRFC2047String(), but with a crucial difference: Instead of encoding the complete 0040 * string as a single encoded word, the string will be split up at control characters, and only parts of 0041 * the sentence that really need to be encoded will be encoded. 0042 */ 0043 [[nodiscard]] QByteArray encodeRFC2047Sentence(QStringView src, 0044 const QByteArray &charset); 0045 0046 /** 0047 Encodes string @p src according to RFC2231 using charset @p charset. 0048 0049 @param src source string. 0050 @param charset charset to use. 0051 @return the encoded string. 0052 */ 0053 [[nodiscard]] QByteArray encodeRFC2231String(QStringView src, 0054 const QByteArray &charset); 0055 0056 } // namespace KMime 0057